<?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[Assigning Qt Item to Property]]></title><description><![CDATA[<p dir="auto">Hello Qt Friends :),</p>
<p dir="auto">I have created following item named BasicStyle.qml:</p>
<pre><code>import QtQuick 2.0

Item {
	property color backgroundColor: "red"
}
</code></pre>
<p dir="auto">and item OtherStyle.qml that 'derives' from it:</p>
<pre><code>import QtQuick 2.0

BasicStyle {
	backgroundColor: "green"
}
</code></pre>
<p dir="auto">Now I would like to use like this:</p>
<pre><code>import QtQuick 2.12
import QtQuick.Window 2.12

Window {
	visible: true
	width: 640
	height: 480
	title: qsTr("Hello World")

//	property BasicStyle basicStyle: BasicStyle
	property BasicStyle basicStyle: OtherStyle

	color: basicStyle.backgroundColor
}
</code></pre>
<p dir="auto">However all I can get is:</p>
<pre><code>QML debugging is enabled. Only use this in a safe environment.
qrc:/main.qml:13: TypeError: Cannot read property 'backgroundColor' of null
qrc:/main.qml:11:2: Unable to assign QQuickWindowQmlImpl_QML_1 to BasicStyle_QMLTYPE_0
</code></pre>
<p dir="auto">Do you have any idea what I'm missing here?</p>
]]></description><link>https://forum.qt.io/topic/114610/assigning-qt-item-to-property</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 04:51:36 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/114610.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 May 2020 13:26:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Assigning Qt Item to Property on Sun, 10 May 2020 12:09:03 GMT]]></title><description><![CDATA[<p dir="auto">@LeLev Thank you sir :-). I already have seen the styling singleton. However I didn't want to use it.</p>
<p dir="auto">Thanks for pointing missing: {}. Adding brackets solved the problem.</p>
]]></description><link>https://forum.qt.io/post/593802</link><guid isPermaLink="true">https://forum.qt.io/post/593802</guid><dc:creator><![CDATA[poor_robert]]></dc:creator><pubDate>Sun, 10 May 2020 12:09:03 GMT</pubDate></item><item><title><![CDATA[Reply to Assigning Qt Item to Property on Fri, 08 May 2020 13:58:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/poor_robert">@<bdi>poor_robert</bdi></a> hi<br />
please see Style Singleton  here <a href="https://wiki.qt.io/Qml_Styling" target="_blank" rel="noopener noreferrer nofollow ugc">https://wiki.qt.io/Qml_Styling</a></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/poor_robert">@<bdi>poor_robert</bdi></a> said in <a href="/post/593553">Assigning Qt Item to Property</a>:</p>
<blockquote>
<p dir="auto">Do you have any idea what I'm missing here?</p>
</blockquote>
<p dir="auto">i think you need brackets after OtherStyle to make it work</p>
<pre><code>property BasicStyle basicStyle: OtherStyle{}
</code></pre>
]]></description><link>https://forum.qt.io/post/593556</link><guid isPermaLink="true">https://forum.qt.io/post/593556</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Fri, 08 May 2020 13:58:39 GMT</pubDate></item></channel></rss>