Unsolved Pressing the "Enter" key triggers unwanted response from a Button
-
I have an application with many Buttons, Widgets, Lables, etc...
I noticed that every time I press the Enter key - regardless of which of the many widgets has focus - it triggers thepressed()
signal associated with the "Refresh" Button you see below in the picture:I assume it has something to do with the fact that this Button is, for some reason, surrounded with Bold frame (unlike the "Initialize Logger" Button, for example, as you can see in the pic).
- What does it mean when the Refresh Button has Bold frame?
- How do I prevent Enter key press to invoke this signal?
Thanks
-
@Absurd
I thought that bold button is the one with focus, though I could be mistaken?You don't say anything about what widget this button is on? A
QDialog
has a default button, https://doc.qt.io/qt-5/qdialog.html#default-button, is that you? If so, clear the button from being default? -
See below pic of how roughly widgets are layed out.
No matter who has focus - for example - it could be some Radio Button on the uppermost QWidget that you see in the pic - the Refresh Button would still have this Bold frame around it - and Enter key will invoke it... -
@Absurd
And you read where I wroteA QDialog has a default button, https://doc.qt.io/qt-5/qdialog.html#default-button, is that you? If so, clear the button from being default?
and acted on unsetting the default button, right?
-
I did.
On that "Refresh" button I invoked setDefault(false) but it didn't help... -
@Absurd
Not sure. To verify or eliminate this from being the issue, why don't you instead make the Initialize Logger button the default, and see if that changes what happens:self.btnInitializeLogger.setDefault(true);
-
Hi,
<enter> key will always trigger default button as this is default shortcut key. Default button is usually with bold shadow on Windows - the focus is marked differently.Please check autodefault properties of the buttons - if the buttons are in the button group, check also settings there.