Reputation: 794
Consider this situation:
For a button on a widget: if there is a chance that the button's clicked()
slot is delivered (processed) after the widget (that contains the button) gets hided by explicitly calling hide()
?
For instance, suppose that there is a timer, and in its timeout()
slot, widget.hide()
gets called. Coincidentally, The user clicks the button just at the same time time is up.
The question is: Is there a chance that the button's clicked()
slot get called after timer's timeout()
slot (which hides the widget that contains the button)?
Upvotes: 1
Views: 456
Reputation: 11555
No, the main thread in synchronous respect the GUI actions, so you cannot change the visibility of an object living in the main thread (like your QPushButton
) exactly at the same time an user is clicking on it. Also, unless you 're on a multithread app with different events loops, your QTimer
will be processed in the main thread too, so it is synchronous respect the UI. In few words: you may get a millisecond concurrence (clicking immediately before hiding it), but not actual parallelism.
If you care about this, maybe you can set a small delay before actually processing the click, just to check if the button was clicked but immediately hidden. In this case you can ignore the user input but it would be confusing. Another option would be to delay hiding the button if it was clicked, so the user doesn't get the wrong visual feedback.
Upvotes: 1