QT窗体水平垂直居中问题

解决办法:可以在窗体的构造函数中添加如下代码:

//---------------------可完成窗体水平垂直居中-----------------
this->resize(1024,768); //窗体大小
//窗体居中
QDesktopWidget* desktop = QApplication::desktop();
int width = desktop->width();
int height = desktop->height();
move((width - this->width())/2, (height - this->height())/2);
//--------------------------------------------------------------

posted on 2013-03-06 11:00  Q11三工鸟yue  阅读(553)  评论(0编辑  收藏  举报