class Main(QWidget, Ui_Form): def __init__(self): super(Main, self).__init__() self.setupUi(self) self.textEdit.setReadOnly(True) # 设置为只读 QTimer.singleShot(0, self.thread_check) # 延迟执行 # textEdit滚动条跟踪内容向下 def append_text_and_scroll(self,text): self.textEdit.append(text) self.textEdit.ensureCursorVisible() self.thread_check(): """业务逻辑""" ... # 使用1: self.append_text_and_scroll(f"商品ID:{obj.get('id')} 商品名:{obj.get('name')} ...入库成功") ... if __name__ == "__main__": app = QApplication(sys.argv) # app.setStyleSheet(open("Network.qss", encoding='utf8').read()) # qss文件引入 ui = Main() ui.show() # 滚动条自动下降 for i in range(10): QApplication.processEvents() sys.exit(app.exec_())
标签:__,text,self,PYQT5,滚动条,textEdit,app From: https://www.cnblogs.com/wanghong1994/p/17626572.html