A vexing problem with the order of signals between a text input and a button [SOLVED]

  • I have a bit of a vexing problem. I have a text input, that after it loses focus, fires a slot that sets a label on the form and begins an operation. This is fine. However when the user clicks the cancel button on the form while the text input has focus, it necessarily causes the text input to lose its focus. Even though the user wants the window to go away, which it does, the label text and operation begin, and the user sees this for a split second. I need to figure out a way to not fire the lost focus signal if the user clicks the cancel button. I am not sure how to achieve that with Qt.

  • I'm not sure what you're trying to achieve. It makes sense that the text box will lose focus when a button is clicked. This is standard behavior. The only thing I can think of is to keep track of the currently focused widget within your window and then return focus to the last focused widget when the user clicks Cancel. Do you have any sample code demonstrating the problem?

  • I solved it. I was trying to achieve responding to the text box losing focus in a different way if the cancel button was clicked. The way I did this was to check to see that whatever widget did have focus was not the cancel button.

  • I'm glad to hear you solved the problem.

  • Moderators

    Please be sure and edit the thread title to add [Solved]. Thanks!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.