qt5 窗口启动居中显示
main.cpp里面修改
#include "mainwindow.h"
#include <QApplication>
#include <QScreen>
#include <QDesktopWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
//w.show();
//移动窗体到屏幕中央
QRect rect = w.frameGeometry();
QDesktopWidget desktop;
QPoint centerPoint = desktop.availableGeometry().center();
rect.moveCenter(centerPoint);
w.move(rect.topLeft());
w.show();
return a.exec();
}