[PyKDE] How can I prevent a QLable from eating MouseEvents?

Markus Gritsch gritsch at iue.tuwien.ac.at
Fri May 25 19:17:12 BST 2001


Hi!

How can I prevent a QLable from eating MouseEvents?  If I click
outside the lable in the following example, mousePressEvent() is
called, if I click on the lable it is not.  What can I do to receive
MouseEvents in any case?


import sys
from qt import *

class Form1(QDialog):
    def __init__(self, parent=None, name='Form1', modal=0, fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)

        self.resize(120,60)
        self.setCaption(self.tr('Form1'))

        self.TextLabel1 = QLabel(self, 'TextLabel1')
        self.TextLabel1.setGeometry(QRect(30,20,61,15))
        self.TextLabel1.setText('TextLabel1')

    def mousePressEvent(self, mouseEvent):
        print 'click'

if __name__ == '__main__':
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
    w = Form1()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()






More information about the PyQt mailing list