[PyQt] How to get an event after an Enter key is pressed?

Igor Prischepoff igor at tyumbit.ru
Fri Jun 6 07:01:23 BST 2008


I think QAction is the way to go:
something like this works for me:

        delrecords = QtGui.QAction(self) # create action
        delrecords.setShortcut(QtCore.Qt.Key_Delete) # set shortcut key for
that action
        <YOUR_WIDGET_HERE>.addAction(self.delrecords) #  assign action to
widget
        self.connect(self.delrecords, QtCore.SIGNAL("triggered()"),
deleteRecords) # connect event <Delete key> is pressed in YOUR_WIDGET.

 

---
igor at tyumbit.ru


 

  _____  

From: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of IloChab
Sent: Friday, June 06, 2008 12:02 AM
To: PyQt at riverbankcomputing.com
Subject: [PyQt] How to get an event after an Enter key is pressed?


I wrote an application where I display sql data on a
QTableView+QSqlQueryModel read only table.

The current version allows you to select via mouse a record on that table
and then add it to an other one, pressing an add-button.

I'd like to give an alternate way to do this: after record line is selected
on the table I'd like to be called on the pression of enter's key and react
to it just like if the add button was pressed.

If is possible to obtain this behaviour I'd like to trap an other button
too:
I'd like to be called when delete's key is pressed while the record line is
selected.

Thanks in advance for your help.
Ciao
Licia


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080606/1bddf016/attachment.html


More information about the PyQt mailing list