2018-01-19:Qt5实现窗口居于屏幕中间

#include 
#include "hellodialog.h"
#include 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
//    QDesktopWidget * desktop=QApplication::desktop();
    QDesktopWidget * desktop=qApp->desktop();//qApp=QApplication *

    HelloDialog w;
    w.move(desktop->width()/2 - w.width()/2, desktop->height()/2 - w.height()/2);//w.move(left, top)
    w.show();
    return a.exec();
}

```

你可能感兴趣的:(2018-01-19:Qt5实现窗口居于屏幕中间)