Reputation: 3741
I have this small 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 display a QWidget
which displays a QMessageBox
after two seconds.
If I am resizing my main window when the popup is displayed, my mouse cursor does not come back to normal (it keeps a "resizing a Window" look) and the interface is completely frozen. I cannot close the popup and I cannot move my mouse over the Taskbar.
The only solution is to navigate with ALT+TAB to Visual studio and stop the debugger.
System (if it matters):
My questions:
Upvotes: 4
Views: 695
Reputation: 3741
According to Digia Support, this is a bug. However, they provide an acceptable workaround.
Just before the QMessageBox::critical
we can add a ReleaseCapture();
like this:
#ifdef Q_OS_WIN
ReleaseCapture();
#endif
The behavior goes back to Qt 4.7 though (cf comment from user3183610). The window will snap back to its original size.
Upvotes: 1