c++ - Make QDialog modal to operating system -


is possible if qdialog instance exec()uted, entire operating system blocked until user closes dialog? in following minimal example dialog blocks parent widget not os elements outside of qt application.

rootwindow.h

#ifndef rootwindow_h #define rootwindow_h  #include <qapplication> #include <qmainwindow> #include <qtdebug> #include <qdialog> #include <qpushbutton> #include <qmessagebox> #include <qboxlayout>  class rootwindow : public qmainwindow {     q_object  private:      qwidget *widgetcentral;     qboxlayout *layoutmain;     qpushbutton *button;     qdialog *dialog;  public:      rootwindow(qwidget *parent = 0, qt::windowflags flags = 0);     ~rootwindow();  private slots:      void slotclicked(); };  #endif // rootwindow_h 

rootwindow.cpp

#include "rootwindow.h"  rootwindow::rootwindow(qwidget *parent, qt::windowflags flags): qmainwindow(parent, flags) {     setcentralwidget( widgetcentral = new qwidget );     widgetcentral->setlayout( layoutmain = new qboxlayout(qboxlayout::lefttoright) );     layoutmain->addwidget(button = new qpushbutton("click me"));      dialog = new qdialog(this);     dialog->setmodal(true);     dialog->setwindowmodality(qt::applicationmodal);      connect(button, &qpushbutton::clicked, this, &rootwindow::slotclicked); }  rootwindow::~rootwindow() {  }  void rootwindow::slotclicked() {     int = dialog->exec();     qdebug() << "dialog result: " << i; } 

main.cpp

#include "rootwindow.h"  int main(int argc, char *argv[]) {     qapplication a(argc, argv);      rootwindow w;     w.show();      return a.exec(); } 

short answer: can't. there may way using native api, doubt it.

however, there way can archive similar behavior: show frameless fullscreen window opacity of 1% - window invisible user, block mouse input. show normal dialog on top of window.

please note approach merely workaround , not work multiple desktops. in addition that, applications (like task-manager) still stay on top of window. keyboard shortcust alt+tab, windows-key , others still work normally. , more...

and last not least: if could, shouldn't. blocking whole computer bad behavior application. showing normal, application modal dialog should enough! if user doesn't want pay attention program, should not force him!


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -