QMessageBox msgBox(this);
msgBox.setMinimumSize(QSize(259, 116));//设置最小对话框,否则可能存在警告
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
setGeometry: Unable to set geometry 100x30+825+456 on QWidgetWindow/'QMessageBoxClassWindow'. Resulting geometry: 259x116+825+456 (frame: 3, 25, 3, 3, custom margin: 0, 0, 0, 0, minimum size: 259x116, maximum size: 259x116).
网上搜到一些,但似乎没啥用,结合提示大体上是说子窗口大小不固定,超过父窗口大小。如此就直接设置子窗口为最小大小好了。。。
msgBox.setMinimumSize(QSize(259, 116));//设置最小对话框,否则可能存在警告