Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt QTextEdit: Detect change Event

I'm overwriting some events in PyQT QTextEdit, for example:

class myTextEditor(QTextEdit):
    def keyPressEvent(self,e):
                print 'key pressed'
        return super(myTextEditor, self).keyPressEvent(e)

Howewer, the changeEvent, documented here, doesn't seem to work. Here's my code

def changeEvent(self,e):
    print 'change'
    return super(myTextEditor, self).changeEvent(e)

There's no error but the event isn't processed.

Any ideas how to use a changeEvent (when the text is changed) in PyQt for a QTextEdit ?

like image 674
edi9999 Avatar asked Jul 26 '13 19:07

edi9999


1 Answers

changeEvent is not related to changing text edit's content. It addresses only general QWidget state changes. See this page to get the list of events related to this method.

You should connect to the QTextEdit::textChanged() signal to track text changes.

like image 171
Pavel Strakhov Avatar answered Sep 20 '22 21:09

Pavel Strakhov