我试图继承QTextEdit并覆盖mouseMoveEvent。我收到错误" TypeError:PySide.QtGui.QAbstractScrollArea不是QTextEdit2"的直接基类。我究竟做错了什么?滚动区域不应该被继承吗?
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class QTextEdit2(QTextEdit):
def __init__(self, parent=None):
super(QTextEdit, self).__init__(parent)
self.setMouseTracking(True)
def mouseMoveEvent(self, event):
print("mouseMoveEvent: x=%d, y=%d" % (event.x(), event.y()))
app = QApplication(sys.argv)
window = QTextEdit2()
window.show()
sys.exit(app.exec_())