The reason for this is that you are calling you message box in a modal state with exec().If the user types in the control and then clicks the button the messagebox pops but the button gets stuck being drawn looking like it’s pressed. How can I make that stop?
This causes the applications even loop to wait for the message box to be dismissed, and therfore, the paintEvent for the pushbuttons is not being handled until the message box is not dismissed.
What you can do is:
1. Rethink your design. If the user is shifting input focus from a control, when the application logic states that this should not be allowed, its better to force the focus to stay on the focused control than to send a message box.
You could in addition to forcing the focus, have somewhere a message saying why it is being done, similar to what many applications do in the status bar.
2. Show the message box with show() and not exec(), but then it wont be modal, can be covered by other windows, and can bring to that that it will be immediately covered by another window so that the user not even notice it was popped.
Bookmarks