犀利小猫

日积月累 滴水石穿

导航

Qt窗口在屏幕上居中显示

方法 1、mian函数中

    MainWindow w;
    w.show();
   w.move ((QApplication::desktop()->width() - w.width())/2,(QApplication::desktop()->height() - w.height())/2);

 

 

方法2、MainWindow 的构造函数中

   MainWindow::MainWindow()

{

    this->move ((QApplication::desktop()->width() - this->width())/2,(QApplication::desktop()->height() - this->height())/2);

}

posted on 2011-12-20 16:01  犀利小猫  阅读(70)  评论(0)    收藏  举报