每当我在 QLineEdit 中输入一些数据时,为什么 textChanged 事件没有发生?
from PyQt4.Qt import Qt, QObject,QLineEdit
from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT
from PyQt4 import QtGui, QtCore
import sys
class DirLineEdit(QLineEdit, QtCore.QObject):
"""docstring for DirLineEdit"""
@pyqtSlot(QtCore.QString)
def textChanged(self, string):
QtGui.QMessageBox.information(self,"Hello!","Current String is:\n"+string)
def __init__(self):
super(DirLineEdit, self).__init__()
self.connect(self,SIGNAL("textChanged(QString&)"),
self,SLOT("textChanged(QString *)"))
app = QtGui.QApplication(sys.argv)
smObj = DirLineEdit()
smObj.show()
app.exec_()
一切对我来说似乎都是正确的,我错过了什么?