Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyQt QTextEdit:检测更改事件_Python_Qt_Events_Pyqt_Pyqt4 - Fatal编程技术网

Python PyQt QTextEdit:检测更改事件

Python PyQt QTextEdit:检测更改事件,python,qt,events,pyqt,pyqt4,Python,Qt,Events,Pyqt,Pyqt4,我正在覆盖PyQT QTextEdit中的一些事件,例如: class myTextEditor(QTextEdit): def keyPressEvent(self,e): print 'key pressed' return super(myTextEditor, self).keyPressEvent(e) 然而,变更事件似乎不起作用。这是我的密码 def changeEvent(self,e): print 'change

我正在覆盖PyQT QTextEdit中的一些事件,例如:

class myTextEditor(QTextEdit):
    def keyPressEvent(self,e):
                print 'key pressed'
        return super(myTextEditor, self).keyPressEvent(e)
然而,变更事件似乎不起作用。这是我的密码

def changeEvent(self,e):
    print 'change'
    return super(myTextEditor, self).changeEvent(e)
没有错误,但未处理事件


如何在PyQt中使用changeEvent(当文本发生更改时)进行QTextEdit?

changeEvent
与更改文本编辑的内容无关。它只处理一般的QWidget状态更改。请参阅以获取与此方法相关的事件列表


您应该连接到
QTextEdit::textChanged()
信号以跟踪文本更改。

以下是我尝试的:
self.textChanged.triggered.connect(self.changeText)
。我得到以下信息:
pyqtsignal必须绑定到Qobject,而不是mytexteditor
尝试删除
。触发的
。它肯定不应该在那里。可能是
self
不是合适的
QObject
。请参阅中的一个示例。事实上,在连接之前,我忘记了执行
super(mytextdeditor,self)。\uuu init\uuuu(父级)
b。谢谢有效的是self.textdedit.textChanged.connect(self.doSomething)