Issue
i have one UI with QtextEdit,
(1) i want to update QtextEdit and main UI can display realtime and no stuck. when use sleep ,not work as i want.
(2) i want have make one function and pass parameter to it, and the QtestEdit can update display real time
self.pButton_torun.clicked.connect(self.mytodo)
def mytodo(self):
self.progress_textEdit.append(u"==== 20 % first step finish")
#after 2 sec
self.progress_textEdit.append(u"==== 40 % second step finish")
#after 2 sec
self.progress_textEdit.append(u"==== 60 % third step finish")
#after 2 sec
self.progress_textEdit.append(u"==== 80 % forth step finish")
Solution
Try using processEvents()
:
def mytodo(self):
self.progress_textEdit.append(u"==== 20 % first step finish")
QApplication.processEvents()
# etc...
This is a bit of a workaround though, down the track you might also want to consider using separate threads.
Answered By - 101
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.