<?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[qmlRegisterTypeSingleton with contextData error while using PySide6]]></title><description><![CDATA[<p dir="auto">I've been having this issue for a long time now. The existing code worked fine for years and didn't start failing until after a QT update over six months ago. If you register a singleton using PySide6, you will get a 'Cannot assign object to list property "contextData"' error message when the QML code has a ListModel. This happens even if the singleton is not being used by the QML code. If you remove qmlRegisterSingletonType, the error goes away. I've searched the internet and have not seen this error happening due to adding a singleton, so I'm not sure what's going on.</p>
<pre><code># singleton.py

from PySide6.QtCore import Qt
from PySide6.QtCore import QObject

class Singleton(QObject):

    def __init__(self):
        super().__init__()
</code></pre>
<pre><code># app

import sys
from PySide6.QtCore import Qt, QObject, QAbstractListModel, QUrl, QByteArray, Signal, Slot, Property
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtQml
from singleton import Singleton 

_singleton = Singleton()

def singleton_callback(self):
    return _singleton

if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    # This Fails 
    QtQml.qmlRegisterSingletonType(Singleton, 'Test', 1, 0, 'Singleton',singleton_callback)

    # This Works
    #QtQml.qmlRegisterType(Singleton, 'Test', 1, 0, 'Singleton')

    engine.quit.connect(app.quit)
    engine.load('main.qml')
    sys.exit(app.exec())
</code></pre>
<pre><code>// main.qml
import QtQuick
import QtQuick.Controls
import Test 1.0

ApplicationWindow {
    id: main

    width: 450 
    height: 450 
    title: "Singleton Test" 
    visible: true

    ListModel { id: myModel }

    Component.onCompleted: {}
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/160671/qmlregistertypesingleton-with-contextdata-error-while-using-pyside6</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 00:12:12 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/160671.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jan 2025 15:53:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Tue, 04 Feb 2025 11:05:22 GMT]]></title><description><![CDATA[<p dir="auto">You are doing things out of order.</p>
<p dir="auto">You need to register the Singleton before creating the engine.</p>
]]></description><link>https://forum.qt.io/post/820002</link><guid isPermaLink="true">https://forum.qt.io/post/820002</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 04 Feb 2025 11:05:22 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Tue, 04 Feb 2025 20:17:10 GMT]]></title><description><![CDATA[<p dir="auto">You're welcome !</p>
<p dir="auto">You know, inverting lines can happen quickly and innocuously :-)<br />
Anyway, now you're back on track.</p>
]]></description><link>https://forum.qt.io/post/820041</link><guid isPermaLink="true">https://forum.qt.io/post/820041</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 04 Feb 2025 20:17:10 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Tue, 04 Feb 2025 20:01:02 GMT]]></title><description><![CDATA[<p dir="auto">Sorry about the late reply; I got busy with work. That fixed it! It's kind of odd since it always worked fine up until a few months ago. I'll have to look in the repo to see if something was changed that I forgot about, but I don't remember changing anything in the source at that time. Anyway, thank you for the help!</p>
]]></description><link>https://forum.qt.io/post/820037</link><guid isPermaLink="true">https://forum.qt.io/post/820037</guid><dc:creator><![CDATA[RLayman]]></dc:creator><pubDate>Tue, 04 Feb 2025 20:01:02 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Tue, 04 Feb 2025 11:05:22 GMT]]></title><description><![CDATA[<p dir="auto">You are doing things out of order.</p>
<p dir="auto">You need to register the Singleton before creating the engine.</p>
]]></description><link>https://forum.qt.io/post/820002</link><guid isPermaLink="true">https://forum.qt.io/post/820002</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 04 Feb 2025 11:05:22 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Fri, 24 Jan 2025 12:37:46 GMT]]></title><description><![CDATA[<p dir="auto">I am using Pyside 6.8.1.1-2 with Qt 6.8.1-1 on an ArchLinux system. This issue has been going on for over six months, and it's been updated several times since then, so it's not a recent issue. I've also wiped the whole system and done a clean install, but I still have the same issue.</p>
]]></description><link>https://forum.qt.io/post/819412</link><guid isPermaLink="true">https://forum.qt.io/post/819412</guid><dc:creator><![CDATA[RLayman]]></dc:creator><pubDate>Fri, 24 Jan 2025 12:37:46 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Wed, 22 Jan 2025 19:48:06 GMT]]></title><description><![CDATA[<p dir="auto">Sorry, I misread something and thought you were using PyQt6...</p>
<p dir="auto">Which version of PySide6 are you using ?<br />
How did you install it ?</p>
]]></description><link>https://forum.qt.io/post/819302</link><guid isPermaLink="true">https://forum.qt.io/post/819302</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 22 Jan 2025 19:48:06 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Wed, 22 Jan 2025 12:48:05 GMT]]></title><description><![CDATA[<p dir="auto">I'm assuming this is an issue between PySide6 and Qt, but I'm not aware of who is to blame.</p>
]]></description><link>https://forum.qt.io/post/819281</link><guid isPermaLink="true">https://forum.qt.io/post/819281</guid><dc:creator><![CDATA[RLayman]]></dc:creator><pubDate>Wed, 22 Jan 2025 12:48:05 GMT</pubDate></item><item><title><![CDATA[Reply to qmlRegisterTypeSingleton with contextData error while using PySide6 on Tue, 21 Jan 2025 19:36:11 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Do you have the same issue with PySide6 ?</p>
]]></description><link>https://forum.qt.io/post/819242</link><guid isPermaLink="true">https://forum.qt.io/post/819242</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 21 Jan 2025 19:36:11 GMT</pubDate></item></channel></rss>