[PyQt] overriding mousePressedEvent not working with QTextEdit

lokev modern.zamurai at gmail.com
Sat Feb 27 23:35:43 GMT 2010


Hi guys

in short:

In the following class, how come only the last method appends to the
TextEdit ?

class MyTextEdit(QTextEdit):
    def __init__(self, parent = None):
        QTextEdit,__init__(self, parent)

    def mousePressEvent(self, event):
        if event.buttons() == Qt.LeftButton and event.modifiers() ==
Qt.ShiftModifier:
            pos = event.pos()
            self.append("(%s,%s)" % (pos.x(), pos.y())

    def mouseReleaseEvent(self, event):
        if event.modifiers() == Qt.ShiftModifier:
            pos = event.pos()
            self.append("(%s,%s)" % (pos.x(), pos.y())

    def mouseMoveEvent(self, event):
        if event.buttons() == Qt.LeftButton and event.modifiers() ==
Qt.ShiftModifier:
            pos = event.pos()
            self.append("(%s,%s)" % (pos.x(), pos.y())

I'm lost,
thanks guys

- Ole Johan 
-- 
View this message in context: http://old.nabble.com/overriding-mousePressedEvent-not-working-with-QTextEdit-tp27731934p27731934.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list