Q桥接和显示QMessageBox
QWidget and showing of QMessageBox
我有一个QWidget,它在show事件上显示一个QMessageBox。我已经覆盖了QWidget的showEvent函数。问题是,消息框首先显示,小部件的其余部分稍后显示。我该如何解决此问题?
void InstallScreen::showEvent( QShowEvent *s )
{
QMessageBox::about( m_main, "One Click Installer",
QString( "The following repositories will be added n %1" ).arg( repoList ) );
QMessageBox::about( m_main, "One Click Installer",
QString( "The following packages will be installed n %1" ).arg( packList ) );
}
使用延迟调用来显示小部件,例如,将小部件显示代码放在插槽中,并使用QTimer::singleShot以0秒的延迟调用它。
这将允许showEvent在显示小部件之前完全处理并安排主循环上的任何重绘事件。这将使小工具&消息框相互独立显示/绘制/重新绘制。
protected:
void MyWidget::showEvent(...) {
...
QTimer::singleShot(0, this, SLOT(showMessageBox());
}
private slots:
void MyWidget::showMessageBox() {
QMessageBox::information(...); // or whatever
}
如果您需要一些额外的余量(无论出于何种原因),请将计时器延迟设置为50或100毫秒。
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 字符串-C++后显示的随机字符
- 继承期间显示未知行为的子类
- 仅使用绝对值对数组进行排序,并在C++中显示实际值
- 程序崩溃并显示"std::out_of_range"错误
- 如何在C++中用std::cout正确显示带十六进制的字符串文本
- 为什么在C的循环中使用printf的Rust代码不显示输出,而在C++的循环中显示std::cout
- 从数据库实时显示QT c++中的数据
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 显示错误输出的简单数组排序程序
- Qt自定义QPush按钮未显示在布局上
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 如何从QDialog的常量方法显示QMessageBox?
- QMessageBox:无法在框中显示文本(使用 c++)
- 显示带有多个参数的QmessageBox
- 如何防止显示 QMessageBox 时出现双槽调用
- Q桥接和显示QMessageBox
- 在QmessageBox中显示图像
- 当添加到现有应用程序时,QDialog或QMessageBox显示Qt::BusyCursor