任务之前禁用QPushButton(Disabling QPushButton before a t

2019-10-17 12:53发布

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.

Answer 1:

你可以做:

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

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

更新了文档注释



文章来源: Disabling QPushButton before a task