Pyqt-qobject::connect:cannot Queue arguments ... Error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.