(转载)QT主窗体在屏幕居中显示

(转载)http://blog.csdn.net/xiexiaopingroma/article/details/5791515

 

#include <QtGui>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDesktopWidget* desktop = QApplication::desktop();
    int width = desktop->availableGeometry(-1).width();
    int height = desktop->availableGeometry(-1).height();

    MainWindow w;
    w.move((width - w.width()) / 2, (height - w.height()) / 2);
    w.show();

    return a.exec();
}

 

 

 


posted @ 2013-05-13 18:13  robotke1  阅读(291)  评论(0编辑  收藏  举报