我目前正在使用静态调用QMessageBox::critical()
消息框,我真的需要它保持在所有窗口的顶部。有人知道如何实现它吗?
只需要静态版本QMessageBox
。
提前致谢。
我目前正在使用静态调用QMessageBox::critical()
消息框,我真的需要它保持在所有窗口的顶部。有人知道如何实现它吗?
只需要静态版本QMessageBox
。
提前致谢。
With the static method QMessageBox::critical()
this is not possible.
You will have to use the non-static version, so you can modify the window flags:
QMessageBox dlg(QMessageBox::Critical, tr("YourTitle"), tr("YourErrorMessage"));
dlg.setWindowFlags(dlg.windowFlags() | Qt::WindowStaysOnTopHint);
dlg.exec();
Note that there is still no guarantee that the window manager really applies this setting. (that's why it's called hint)
But... in my opinion you should not do that - no application (besides the operating system itself) should consider itself that important... For your users this could be quite annoying, so only do it if in your error case it is not possible or dangerous to continue working with the whole system.