就在界面的CPP文件中的构造函数里面写

 

 1 #include <QDesktopWidget>    //注意一定要这个头文件
2 #include "ala_mainview.h"
3 #include "ui_ala_mainview.h"
4
5 Ala_MainView::Ala_MainView(QWidget *parent) :
6 QMainWindow(parent),
7 ui(new Ui::Ala_MainView)
8 {
9 ui->setupUi(this);
10 //注意一定要在这个setupUi的后面
11 //写上下面的四句,最后两句选中其一即可
12 int x=(QApplication::desktop()->width() - this->width())/2;
13 int y=(QApplication::desktop()->height() - this->height())/2;
14 this->setGeometry ( x,y, this->width(),this->height());
15 //this->move (x,y);
16 }



相关文章:

  • 2021-06-03
  • 2021-11-13
  • 2021-10-18
  • 2021-12-19
  • 2021-06-24
  • 2021-11-21
  • 2021-06-14
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案