PyQt QTextEdit: Detect change Event

11,318

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.

Share:
11,318
edi9999
Author by

edi9999

Open-source developper for docxtemplater UI Interface Developper (React, d3, previously angular) I also develop back end services in Node.JS, Golang and in PHP I run a business developping additional functionality for docxtemplater. I write robust software by making sure it is well tested and the tests give fast feedback (about 1s for the full docxtemplater testsuite for example). I love the command line, and use tmux/vim/bash/fzf and I automate my workflows a lot See my resume

Updated on June 10, 2022

Comments

  • edi9999
    edi9999 almost 2 years

    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 ?