c++ - 主窗口打开后显示一个按钮
问题描述
如何在主窗口打开 10 秒后立即显示按钮?
我正在使用 showevent 但如果我在其中进行 10 秒计数,它就会卡住:
void main::showEvent(QShowEvent *event)
{
QWidget::showEvent( event );
QTimer timer;
timer.start(10000);
while(timer.remainingTime() > 0)
{
qDebug() << timer.remainingTime();
if(timer.remainingTime() <= 0)
{
_ui->btn_CloseAd->show();
timer.stop();
}
}
}
解决方案是什么?
解决方案
void main::showEvent(QShowEvent *event)
{
QWidget::showEvent( event );
QTimer::singleShot(10000, _ui->btn_CloseAd, &QWidget::show);
}
推荐阅读
- python-3.x - 正确使用数据类返回项目的值
- mongodb - 调用 mongodb insert,在 react native 中从另一个类中查找函数,返回未定义
- oauth - OAuth 2 刷新令牌实现
- javascript - Tampermonkey 访问页面上的 JSON 调用/ URL?
- laravel - 想在 .htaccess 文件的帮助下删除 index.php
- iphone - 如何减少 AVplayer 中循环音频播放的延迟 - ios swift
- python - 在 Windows 中单击 .lnk 时出现 Jupyter UTF-8 错误
- python-3.x - 从字符串中获取 ord() 函数并返回总和
- json - 用于中间密集层输出的 Keras 回调
- html - foreach循环的JSTL分页