Re: Qthread 问题

楼主: MOONY135 (谈无欲)   2017-12-06 22:03:31
※ 引述《noshare (zzz...)》之铭言:
: 因为想学习使用Qthread方式来避免pyqt的画面会冻结的问题。
: 以下是我的程式码
: class MyWidget(QWidget):
: def __init__(self, parent = None):
: super(MyWidget, self).__init__(parent)
: ...
: def createLayout(self):
: self.button_config= QPushButton(self)
: combo_box_option = ["1","3","5","10","20"]
: self.combo = QComboBox(self)
: for t in combo_box_option:
: self.combo.addItem(t)
: ...
: def __init__(self,parent=None):
: super(MyThread,self).__init__(parent)
: def run(self):
: for i in range(x):
: self.sec_changed_signal.emit(i)
: time.sleep(1)
: 想知道有没有办法让最后一个for循环里面的x值,
: 能够等于前一个class里面最后一行下拉式选择后的config_result
: 或是有其他种写法可以达成在使用循环时,GUI不会出现无法反应的状态。
: 谢谢各位~
我会建议你另外开一个存资料的地方 QList之类的
Qthread去里面更新资料 另外一个地方是给GUI去
读取里面的资料
可能用timer 每秒读
作者: uranusjr (←這人是超級笨蛋)   2017-12-06 22:07:00
QList 没有 thread-safe, 这样读迟早出事

Links booklink

Contact Us: admin [ a t ] ucptt.com