在任务之前禁用 QPushButton [英] Disabling QPushButton before a task

查看:73
本文介绍了在任务之前禁用 QPushButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了 QPushButton 并与特定任务建立了连接.除了这个任务,我想禁用这个 QPushButton.因此,我在任务之前添加了 mypushbutton.setEnabled(False),但它不会像我预期的那样工作,我的任务完成后按钮被禁用.但是,当我删除任务时,它可以工作.

I created QPushButton and made a connection to a specific task. In addition to this task, I would like to disable this QPushButton. Thus I add mypushbutton.setEnabled(False) just before the task, but it won't work as I expected, the button is disabled after my task is done. However, when I remove my task, it works.

推荐答案

您可以:

mypushbutton.setEnabled(False);
QCoreApplication::processEvents();
// do something

http://doc.qt.digia.com/qt/qcoreapplication.html#processEvents

更新了文档评论

这篇关于在任务之前禁用 QPushButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆