Application frozen by QMessageBox

I have this little piece of code:

#include <QApplication>
#include <QWidget>
#include <QBasicTimer>
#include <QMessageBox>

class MyWidget:public QWidget{
public:
    QBasicTimer timer;
protected:
    void timerEvent(QTimerEvent*e){
        if(e->timerId()==timer.timerId()){
            timer.stop();
            QMessageBox::critical(this,"Oups",
                                 "I hope you were not resizing the main window.");
            return;
        }
        QWidget::timerEvent(e);
    }
};

int main(int argc,char*argv[]){
    QApplication app(argc,argv);
    MyWidget w;
    w.timer.start(2000,&w);
    w.show();
    return app.exec();
}

I show a QWidget, which shows QMessageBoxin two seconds. If I resize the main window when the pop-up window is displayed , my mouse cursor does not return to its normal state (it saves "window resizing") and the interface is completely frozen . I cannot close the popup and I cannot move the mouse pointer over the taskbar.

The only solution is to navigate with ALT+ TABin Visual studio and stop the debugger.

System (if that matters):

  • Windows 7 64 bit.
  • Visual Studio 2013 + Addin
  • Qt 5.3.0 alpha

My questions:

  • Is this a known bug?
  • Am I doing something wrong?
  • ?
+4
1

Digia, . .

QMessageBox::critical ReleaseCapture(); :

#ifdef Q_OS_WIN
    ReleaseCapture();
#endif

Qt 4.7, ( cf 3183610). .

+1

Source: https://habr.com/ru/post/1535943/


All Articles