プログラムの「メイン」スレッドでQTextEditコンポーネントを作成し、別のスレッドを開始します。このスレッドはx秒ごとにこのQTextEditを更新しますが、次のエラーが発生します。
QObject: Cannot create children for a parent that is in a different thread.
これは私がそれをしている方法です:
def initGui():
#some gui components
global txt_list
txt_list = QtGui.QTextEdit(w)
txt_list.resize(580,400)
txt_list.move(50, 50)
txt_list.setReadOnly(1)
txt_list.setFont(font_consolas)
#more gui components
def update_list():
t_monitor = threading.Thread(target=monitor_vector)
t_monitor.daemon = True
t_monitor.setName('monitor')
t_monitor.start()
def monitor_vector():
#retrieve info...
lock = threading.Lock
lock = True
txt_list.clear() #clear list, to set the new one
txt_list.setText('updated list')
lock = False
この最後の2行のコードは、上記のエラーを示しています。誰かが私にこれを処理する方法の手がかりを与えることができますか?
ありがとう!