[PyQt] Key return

Milan Hemžal milan at 3trees.cz
Sat Nov 22 18:39:26 GMT 2008


On Saturday 22 November 2008 00:32:30 David Boddie wrote:

i mean: 
if press ENTER on the button with focus - call action for this button ( same 
like if press key SPACE

> On Sat Nov 1 17:46:29 GMT 2008, lucaberto wrote:
> > i need that when i press the Return key, one button intercept the
> > pression of it and process the event Can you explain me how i can do it
>
> On Fri Nov 21 11:02:02 GMT 2008, Milan Hemžal wrote:
> > On Sunday 02 November 2008 18:46:44 Matt Smith wrote:
> > Ok, but i also have this problem.
> >
> > pls. howto use press enter in button if have more button?
>
> All of this depends on how you guys are using those buttons.
>
> If you are using a QDialog subclass, you can make one of the buttons the
> "default" button for the dialog:
>
> http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qdialog.html#defau
>lt
>
> If you are using some other widget to display the buttons, there are other
> ways to connect a key press with a specific button. For example, you could
> create an action with a keyboard shortcut, connect its triggered() signal
> to a push button's animateClick() slot, and add it to the button's parent
> widget:
>
>   # b is the chosen button
>   # w is the button's parent widget
>   action = QAction(w)
>   action.setShortcut(QKeySequence("Return"))
>   w.connect(action, SIGNAL("triggered()"), b, SLOT("animateClick()"))
>   w.addAction(action)
>
> You might need to add another action to the widget if you also want the
> Enter key to have the same effect as the Return key.
>
> David
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-- 
Milan Hemžal
3 Trees s.r.o.
--------------------------
Dřevěné podlahy a koupelny

Kontakt info:
GSM +420 775 393 335
www: www.3trees.cz



More information about the PyQt mailing list