I’ve been developing a desktop application using Qt Creator under Linux (Kubuntu).
Under linux, all is well, but under Windows, in a dialog box, the wrong button is selected by default when the window appears.
There are three buttons: Edit, Continue and Stop.
Continue is marked as ‘AutoDefault’ and ‘Default’.
Stop is marked as ‘AutoDefault’, but not ‘Deafault’.
Edit is marked as neither ‘AutoDefault’ nor ‘Default’, but when the dialog opens, it is selected, and pressing enter presses the Edit button.
The source for the program can be found at https://github.com/megamasha/FlashKard for anyone who wants to try it themselves. The window in question is generated from the ‘resultswindow.ui’ file.
Is this just me? Is this a bug? Just wondering if anyone can see any obvious reason why this doesn’t work (or perhaps it just doesn’t work on my Windows Vista system)
About
QPushButton::default:And more importantly:
Unless you explicitly set
editButton‘s autoDefault to false, it is true. There might be some Windows specifics involved (without further hints, Windows focuses the control with the lowest ID, which is probably the case foreditButton, since it’s created first).Try either setting autoDefault to false, or explicitly call
continueButton.setFocus()