Is it possible to programmatically toggle a QPushButton
? I have a checkable QPushButton
that a user presses to start a process. When the process is done, how can the button's state be changed to unchecked?
runBtn = QPushButton('Run')
runBtn.setCheckable(True)
runBtn.clicked.connect(runProcess)
def runProcess():
time.sleep(5)
runBtn.uncheck() # how should this be done?
this should to the trick.
runBtn.setChecked(False)
although that's not ideal behaviour. toggle buttons should be used for turning things on and off, not indicating that something is in progress. if something is taking time you should change the cursor to a wait cursor and better still show a progress bar/dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With