【发布时间】:2014-04-10 13:47:01
【问题描述】:
我有这么一小段代码:
#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();
}
我显示QWidget,两秒钟后显示QMessageBox。
如果在显示弹出窗口时我正在调整主窗口的大小,我的鼠标光标不会恢复正常(它保持“调整窗口大小”的样子)并且界面完全冻结。我无法关闭弹出窗口,也无法将鼠标移到任务栏上。
唯一的解决方案是使用 ALT+TAB 导航到 Visual Studio 并停止调试器。
系统(如果重要):
- Windows 7 64 位。
- Visual Studio 2013 + 插件
- Qt 5.3.0 alpha
我的问题:
- 这是一个已知的错误吗?
- 我做错了吗?
- 有简单的解决方法吗?
【问题讨论】:
-
我认为您的问题可能与this one有关
-
@maddin45 我不这么认为。我知道我有一个模态对话框。我的问题是我什至无法单击消息框本身。
-
片段根本不起作用...
-
@Samoth 对不起。我发布了一个更正的版本。我在 Qt Creator 和 Visual Studio 中对其进行了测试。
-
这似乎是Qt5中引入的一个bug。我测试并且可以在 5.2.0 中确认相同的行为,但在 4.8.4 中没有