Reputation: 19329
The dialog window has three widgets: QComboBox, QLineEdit and QPushButton. When dialog is shown the QLineEdit is being set as "current" by default. Any keyboard entry performed will be entered straight into QLineEdit field.
Instead of QLineEdit I want QPushButton to be current. So the user could hit a keyboard "Enter" key to trigger the function connected to QPushButton. What flag or attribute of QPushButton needs to be set to achieve this?
Upvotes: 0
Views: 2359
Reputation: 3945
If you are using QtDesigner, with QPushButton selected go to Property Editor and scroll to the bottom, set the Default property checked OR inside your code, button.setDefault(True)
, this feature is specially for what you are looking for. Look here for details.
Upvotes: 1
Reputation: 4286
I suppose, You want to use eventFilter()
to handle keyPressEvent()
. Then You only need
self.pushButton.setFocus()
in QDialog's constructor and install an appropriate eventFilter on pushButton
Upvotes: 0