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