头文件:
#include
代码:
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
......略.......
QDesktopWidget *widget= QApplication::desktop();
move((widget->width()-this->width())/2,(widget->height()-this->height())/2);
......略.......
}
运行效果: