[PyQt] How to catch a mouse event and a key event at the same time

Lukas Hetzenecker LuHe at gmx.at
Tue Apr 14 17:47:30 BST 2009


Hello, try to use this:

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Main(QWidget):
    def __init__(self,  app):
        QWidget.__init__(self)
        self.app = app
        
        self.show()
        
    def mousePressEvent(self, event):
        if (app.keyboardModifiers() == Qt.ControlModifier and event.button() == 
Qt.LeftButton):
            print "Strg + left mouse"

app = QApplication([])
main = Main(app)
app.exec_()

Am Dienstag 14 April 2009 18:17:38 schrieb projetmbc:
> Hello,
> I would like to know when the user uses at the same time the left button
> of the mouse and the key CTRL for example.
>
> Is-it possible ?
>
> Christophe.
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt



More information about the PyQt mailing list