使用PySide子类化QTextEdit时出错

时间:2017-10-09 17:04:06

标签: python qt pyside

我试图继承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_())

0 个答案:

没有答案