Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a QMessageBox on top of all windows

I have created a program that runs alongside an application in fullscreen. I would like the QMessageBox from my program to be displayed on top of the application that runs in fullscreen.

The platform is Windows 7 and i am using Qt.

I have tried:

QMessageBox *msgBox = new QMessageBox;
msgBox->setParent(0);
msgBox->setWindowTitle(title);
msgBox->setText(text);
msgBox->setWindowFlags(Qt::WindowStaysOnTopHint);
msgBox->show();

With no luck. Any hints?

like image 749
Attaque Avatar asked May 07 '14 08:05

Attaque


Video Answer


1 Answers

Try msgBox->raise(); will notify the user in taskbar, using setWindowFlags(Qt::WindowStaysOnTopHint); you eventually could make it stay on top (evtl. minimize/restore). But a windowmanager, not depending on os, by design should not allow any application to just "steal" the focus from another application, therefor the user still needs to activate (click) your window for gaining focus.

like image 140
Sebastian Lange Avatar answered Sep 22 '22 01:09

Sebastian Lange