#include <QDesktopWidget>// 主屏幕居中显示 QDesktopWidget* desktop = QApplication::desktop();QWidget* mainScreen = desktop->screen(0);move((mainScreen->width() - this->width()) / 2, (mainScreen->height() - this->height()) / 2); // this 是要显示的窗口的指针.