Qt编程 窗口居中显示

Qt编程技巧 窗体居中显示 
view plaincopy to clipboardprint?
this->resize(150,150); //窗体大小
//窗体居中
QDesktopWidget* desktop = QApplication::desktop();
int width = desktop->width();
int height = desktop->height();
move((width - this->width())/2, (height - this->height())/2);


PS:resize要放在调整窗体位置前面,不然刚开始的this->width()和this->height()是默认的,再调整就不能保证是居中了

 

posted @ 2011-01-09 15:26  IT人Key  阅读(161)  评论(0编辑  收藏  举报