我需要一点帮助。
我有一个QTextBrowser,在这里,我将所有的标准重定向到它。
self.console_window = QtGui.QTextBrowser()
self.console_window.setReadOnly(True)我现在需要的是自动滚动到底部,这样我就可以看到正在发生的事情,而不需要手动滚动到底部。
我试过这个
scrollBar = self.console_window.verticalScrollBar()
scrollBar.setValue(scrollBar.maximum())但不起作用。
有什么想法吗?
修好了!
def handleOutput(self, text, stdout):
self.console_window.moveCursor(QtGui.QTextCursor.End)
self.console_window.ensureCursorVisible()
self.console_window.insertPlainText(text)
def Console_Window(self):
self.console_window = QtGui.QTextEdit()
self.console_window.setReadOnly(True)发布于 2019-07-07 15:02:15
只是Pyqt5中的一个快速更新。
我的做法有点不同,因为我已经看到需要延迟:
self.scrollbar = self.log_output.verticalScrollBar() #the self.scrollbar is the same as your self.console_window
try:
time.sleep(0.1) #needed for the refresh
self.scrollbar.setValue(10000) #try input different high value
except:
pass #when it is not availablehttps://stackoverflow.com/questions/32945399
复制相似问题