The difference is that the pressed() signal is emitted as soon as the mouse goes down on the button. The clicked() signal is emitted only when the mouse goes down and then comes back up while on the button. This difference has at least three consequences:The clicked signal worked as i always use pressed signal i'll try to understand the difference.
- If you connect to pressed(), then there is no way for the user to cancel the action - whatever is in the slot gets executed as soon as the mouse goes down.
- If the slot connected to pressed() causes the button to lose focus, then the button will never see a mouse release so it stays depressed. This is what happened for you.
- If you connect to clicked() and the user presses the mouse on the button but then moves off the button to release the mouse, there is no signal. This lets the user "cancel" the click before anything happens. The clicked() signal is emitted only if the mouse down and up happen while the mouse is on the button. (The mouse can move off the button while it is pressed, but if it moves back on when it is released, the signal will be emitted).
In general, you should always connect to the clicked() signal for a good user experience.
Bookmarks