0

I'm currently using static called QMessageBox::critical() message box and I really need it to stay on top of all windows. Does somebody has an idea how to implement it?

Only static version of QMessageBox is needed.

Thanks in advance.

BBRodriguez
  • 306
  • 1
  • 4

1 Answers1

0

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.

BBRodriguez
  • 306
  • 1
  • 4