How assign the enter key to a button
Page |
1 |
Hi,
How can I assign the enter key to a button? In other words how can I assign the enter key to a button so that when the enter key is pressed it basically trigers the button.
Thanks
18 replies
No, that does not work. Did you read the documenation on event filters? You need to install it on the top-level widget, subclass your Button, and reimplement the eventFilter method.
Alternatively, and easier: you can use a QShortCut. Just create a shortcut for the Enter key, and connect it’s activated() signal to the click() slot of the button.
No, that does not work. Did you read the documenation on event filters? You need to install it on the top-level widget, subclass your Button, and reimplement the eventFilter method.
I actually did, the problem is that I’m a beginner on Qt as well as on C++, so I don’t completely understand the documentation. In fact I’m having a hard time following your instructions… Sorry!!!
bq. You need to install it on the top-level widget, subclass your Button, and reimplement the eventFilter method.
Too advanced. I know I know, its probably a pain to teach a beginner. I will reread and try again.
Thanks a lot for your help
Why don’t you try try the QShortCut method then? That should be easier…
Having a basic understanding of C++, including classes & objects, inheritance and polymorphism is really needed to work with Qt. If you don’t understand those, then please get a C++ book and learn about them. It will make it much easier for you to understand Qt.
Why don’t you try try the QShortCut method then? That should be easier…
Having a basic understanding of C++, including classes & objects, inheritance and polymorphism is really needed to work with Qt. If you don’t understand those, then please get a C++ book and learn about them. It will make it much easier for you to understand Qt.
I will try the short cut. As far as learning C++, I’m currently taking a class and reading as much as I can.
Thanks a lot for your help!
You must log in to post a reply. Not a member yet? Register here!




