`
womendu
  • 浏览: 1481891 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

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()是默认的,再调整就不能保证是居中了

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics