【发布时间】:2015-11-02 11:25:37
【问题描述】:
以下代码会在 2 秒后关闭我的 QMessageBox。但是我的文字会在盒子关闭时显示,在盒子关闭之前它会快速闪烁。这是怎么回事?
QMessageBox *msgBox = new QMessageBox();
msgBox->setText("Coördinate is being created, please wait...");
msgBox->show();
QTimer::singleShot(2000, msgBox, SLOT(hide()));
这显示,然后在关闭之前我可以看到文本。
更新
在单线程程序中工作:方法WriteMultipleACLCommands() 占用了大量时间。也许这就是问题所在?
QMessageBox *msgBox = new QMessageBox();
msgBox->setText("Coördinate is being created, please wait...");
msgBox->show();
QTimer::singleShot(2000, msgBox, SLOT(hide()));
singleton_SerialPortManager->WriteMultipleACLCommands();
//function writes a few bytes onto a serial connection
【问题讨论】:
-
我尝试了您的代码,但没有看到任何闪烁的内容。我在 Ubuntu 14.04 上使用 Qt 5.5.1。
-
该代码看起来没有任何问题。它更有可能是其他地方的东西。
标签: c++ qt qmessagebox