我有一个QTextBrowser
,我想在里面选择一部分文本,我需要选择的开始和结束的位置。我想用mousePressEvent
和mouseReleaseEvent
来做。这是我的密码
class MainWindow(QMainWindow, TeamInsight.Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
def set_text(self):
self.textBrowser.setText('test strings are here')
textBrowser在主窗口中。如何在textBrowser中为文本实现mousePressEvent
和mouseReleaseEvent
如果您想跟踪事件并且不能覆盖类,解决方案是安装一个事件筛选器,在您的情况下,仅安装
MouseButtonRelease
事件,我们必须筛选QTextBrowser
的viewport()
:相关问题 更多 >
编程相关推荐