Problem
Source:
Class Windows (Qtgui.qwidget): # Creates a widget containing: #-a Qlineedit (status_widget) #-a button, Connec Ted to On_run_clicked def on_run_clicked (self): def update (text): self.widget.setText (text) th Reading. Thread (Target=run, args= (update,)). Start ()
But if you change Qlineedit to Qtextedit, and you use the Append method, you get the following error:
Qobject::connect:cannot queue arguments of type ' qtextcursor '
(Make sure ' qtextcursor ' is registered using Qregistermetatype ().)
Solution
We cannot modify the UI through threads, and the more secure way to modify the user interface is to send a signal to the UI window (signal), and the simpler way is to use Qt threading
Class mythread (Qtcore.qthread): updated = qtcore.pyqtsignal (str) def run ( self ): # do some functionality for i in range ( 10000): self.updated.emit (str (i)) class windows (Qtgui.qwidget): def __init__ ( self, parent = none ): super (windows, self). __init__ (parent) self._thread = mythread (self) self._thread.updated.connect (Self.updatetext) # create a line edit and a button self._button.clicKed.connect (Self._thread.start) def updatetext ( self, text ): self.widget.settext (text)
Pyqt-qobject::connect:cannot Queue arguments ... Error