Passing an argument when starting new QThread() in PyQt

后端 未结 2 611
不知归路
不知归路 2021-01-01 04:29

I have a multi-threaded application written in Python in which one thread \"takes care\" of the GUI, and the other is the worker thread. However, the worker thread has two m

2条回答
  •  旧巷少年郎
    2021-01-01 05:05

    Eli Bendersky's answer is correct, however the order of arguments appears wrong.

    If you call the Worker class like this:

    The argument order that worked for me:

    def __init__(self, parent=None, do_create_data=True):  
    

    The order shown in Eli Bendersky's answer produced this error message for me:

    TypeError: QThread(QObject parent=None): argument 1 has unexpected type 'str'
    

    Not sure why, but I'm sure someone can help explain.

提交回复
热议问题