演示问题的简单代码:
#!/usr/bin/env python
import sys
from PyQt4.QtCore import QObject, SIGNAL
from PyQt4.QtGui import QApplication, QTextEdit
app = QApplication(sys.argv)
def findText():
print(textEdit.find('A'))
textEdit = QTextEdit()
textEdit.show()
QObject.connect(textEdit, SIGNAL('textChanged()'), findText)
sys.exit(app.exec_())
在窗口中输入“A”后,find('A')
仍然返回False
。
问题出在哪里?