<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Make sure &#x27;QTextCursor&#x27; is registered using qRegisterMetaType()]]></title><description><![CDATA[<p dir="auto">Im sure you guys get this alot but im trying to thread and im getting this error:</p>
<pre><code class="language-QObject:">(Parent is QTextDocument(0x1243bfd4290), parent's thread is QThread(0x12437dd1260), current thread is myThread(0x1243c008470)
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)```

Can anyone help?

My thread:

```class myThread(QThread):
    def __init__(self, username, _previous, text):
        
        super().__init__()
        self.username = username
        self._previous = _previous
        self.text = text
        print(dir(QThread))

    
    def run(self):
        
        n = len([k for k in _MESSAGE_COLLECTION.find({'msg': True})])
        while True:
            if n != len([k for k in _MESSAGE_COLLECTION.find({'msg': True})]):

                self.message = _MESSAGE_COLLECTION.find_one({'_id': _ID + n})
                
                self.execute_update()
                n += 1

    def execute_update(self):
        if self.message['from'] != self.username:
            self._previous.append(f'\n\n{self.message["from"]} says: {self.message["message"]}')
            self.text.setPlainText("\n".join(self._previous[::-1]))```

and i call it with 

</code></pre>
<p dir="auto">self.thread = myThread(self.username, self._previous, self.text)<br />
self.thread.start()```</p>
]]></description><link>https://forum.qt.io/topic/129383/make-sure-qtextcursor-is-registered-using-qregistermetatype</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 03:32:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/129383.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Aug 2021 15:36:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Make sure &#x27;QTextCursor&#x27; is registered using qRegisterMetaType() on Fri, 13 Aug 2021 17:05:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/caeden">@<bdi>Caeden</bdi></a> It seems that you have not understood the usefulness or operation of the signals, I recommend you review the official docs. what is <code>_message</code>?</p>
<p dir="auto">If _message is a string then the slot must have the argument:</p>
<pre><code class="language-python">foo_text = "Foo"
self.text_changed.emit(foo_text)
</code></pre>
<pre><code class="language-python">def settext(self, text):
    print(text)
</code></pre>
]]></description><link>https://forum.qt.io/post/675722</link><guid isPermaLink="true">https://forum.qt.io/post/675722</guid><dc:creator><![CDATA[eyllanesc]]></dc:creator><pubDate>Fri, 13 Aug 2021 17:05:32 GMT</pubDate></item><item><title><![CDATA[Reply to Make sure &#x27;QTextCursor&#x27; is registered using qRegisterMetaType() on Fri, 13 Aug 2021 16:53:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eyllanesc">@<bdi>eyllanesc</bdi></a> how can i pass variables through the emit? So i'm doing</p>
<pre><code>self.thread = myThread(self.username, self._previous, self.text)
        self.myThread.text_changed.connect(self.settext)
        self.thread.start()
</code></pre>
<p dir="auto">and</p>
<pre><code>def settext(self):
</code></pre>
<p dir="auto">but i dont know how i can pass the <code>_message</code></p>
]]></description><link>https://forum.qt.io/post/675721</link><guid isPermaLink="true">https://forum.qt.io/post/675721</guid><dc:creator><![CDATA[Caeden]]></dc:creator><pubDate>Fri, 13 Aug 2021 16:53:18 GMT</pubDate></item><item><title><![CDATA[Reply to Make sure &#x27;QTextCursor&#x27; is registered using qRegisterMetaType() on Fri, 13 Aug 2021 16:42:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eyllanesc">@<bdi>eyllanesc</bdi></a> ill try this, thank you!</p>
]]></description><link>https://forum.qt.io/post/675719</link><guid isPermaLink="true">https://forum.qt.io/post/675719</guid><dc:creator><![CDATA[Caeden]]></dc:creator><pubDate>Fri, 13 Aug 2021 16:42:10 GMT</pubDate></item><item><title><![CDATA[Reply to Make sure &#x27;QTextCursor&#x27; is registered using qRegisterMetaType() on Fri, 13 Aug 2021 16:37:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/caeden">@<bdi>Caeden</bdi></a> You should not directly modify the GUI in another thread.</p>
<pre><code class="language-python">class myThread(QThread):
    text_changed = Signal(str)

    def __init__(self, username, _previous):
        super().__init__()
        self.username = username
        self._previous = _previous

    def run(self):
        n = len([k for k in _MESSAGE_COLLECTION.find({"msg": True})])
        while True:
            if n != len([k for k in _MESSAGE_COLLECTION.find({"msg": True})]):

                self.message = _MESSAGE_COLLECTION.find_one({"_id": _ID + n})

                self.execute_update()
                n += 1

    def execute_update(self):
        if self.message["from"] != self.username:
            self._previous.append(
                f'\n\n{self.message["from"]} says: {self.message["message"]}'
            )
            self.text_changed.emit("\n".join(self._previous[::-1]))
            QThread.msleep(10)
</code></pre>
<pre><code class="language-python">self.my_thread = myThread(self.username, self._previous)
self.my_thread.text_changed.connect(self.text.setPlainText)
self.my_thread.start()
</code></pre>
]]></description><link>https://forum.qt.io/post/675718</link><guid isPermaLink="true">https://forum.qt.io/post/675718</guid><dc:creator><![CDATA[eyllanesc]]></dc:creator><pubDate>Fri, 13 Aug 2021 16:37:44 GMT</pubDate></item></channel></rss>