<?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[[solved]Strange behavior of QML Elements written in Qt]]></title><description><![CDATA[<p dir="auto">Hello guys,</p>
<p dir="auto">I've written my own component in Qt and exposed it to QML to use it in another component.<br />
So long everything works fine.</p>
<p dir="auto">But when I add my new Component twice on my window, the first one gets rendered as expected, but the second one has the font of the title.</p>
<p dir="auto">To make my Problem a little bit more clear I try to give an example:<br />
@Item {<br />
Text {        // a caption<br />
font.bold: true<br />
...<br />
}</p>
<p dir="auto">MyComponent {        // written in Qt, paints a timeline with text underneath<br />
...<br />
}<br />
}@</p>
<p dir="auto">My component looks something like this. I have a Text item as caption, and a small timeline where everything is painted in Qt (the line + text)</p>
]]></description><link>https://forum.qt.io/topic/16223/solved-strange-behavior-of-qml-elements-written-in-qt</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 21:00:36 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16223.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Apr 2012 13:08:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved]Strange behavior of QML Elements written in Qt on Mon, 30 Apr 2012 03:22:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">QDeclarativeView sets the <em>QGraphicsView::DontSavePainterState</em> optimization flag by default, which means any changes you make to the painter (such as <em>painter-&gt;setFont()</em>) in your <em>paint()</em> function need to be undone at the end of the <em>paint()</em> function, or they may "leak" to other items.</p>
<p dir="auto">Regards,<br />
Michael</p>
]]></description><link>https://forum.qt.io/post/137479</link><guid isPermaLink="true">https://forum.qt.io/post/137479</guid><dc:creator><![CDATA[mbrasser]]></dc:creator><pubDate>Mon, 30 Apr 2012 03:22:24 GMT</pubDate></item><item><title><![CDATA[Reply to [solved]Strange behavior of QML Elements written in Qt on Fri, 27 Apr 2012 06:06:10 GMT]]></title><description><![CDATA[<p dir="auto">Ok problem solved. I added a<br />
@QFont font("Arial",10);<br />
painter-&gt;setFont(font);<br />
@<br />
to my Qt component and now everything gets correctly rendered.<br />
Seems that Qt took one of the last font settings used on the same parent qml component.</p>
]]></description><link>https://forum.qt.io/post/137179</link><guid isPermaLink="true">https://forum.qt.io/post/137179</guid><dc:creator><![CDATA[xardas008]]></dc:creator><pubDate>Fri, 27 Apr 2012 06:06:10 GMT</pubDate></item><item><title><![CDATA[Reply to [solved]Strange behavior of QML Elements written in Qt on Fri, 27 Apr 2012 05:42:27 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
Rectangle {<br />
id: rect1<br />
Text {<br />
id: text1<br />
font.bold: true<br />
font.pointSize: 20<br />
}<br />
MyQtComponent{<br />
id: other1<br />
... //(mostly anchors)<br />
}<br />
}</p>
<p dir="auto">Rectangle {<br />
id: rect2<br />
Text {<br />
id: text2<br />
font.bold: true<br />
font.pointSize: 20<br />
}<br />
MyQtComponent {<br />
id: other2    // draws some text with QPainter inside qt, not qml, this one gets the font settings of text1<br />
...<br />
}<br />
}<br />
@</p>
<p dir="auto">In MyQtComponent I use QPainter to draw some text without setting a font explicit.<br />
The problem I have is, that as long as the font settings of text1 is set to 20 and bold, the font of other2 is also in this font setting. The font of other1 is normal. Both components are on the same window.</p>
]]></description><link>https://forum.qt.io/post/137176</link><guid isPermaLink="true">https://forum.qt.io/post/137176</guid><dc:creator><![CDATA[xardas008]]></dc:creator><pubDate>Fri, 27 Apr 2012 05:42:27 GMT</pubDate></item><item><title><![CDATA[Reply to [solved]Strange behavior of QML Elements written in Qt on Thu, 26 Apr 2012 23:30:44 GMT]]></title><description><![CDATA[<p dir="auto">I don't fully understand.  Can you post a complete but minimal example which shows the issue?</p>
]]></description><link>https://forum.qt.io/post/137158</link><guid isPermaLink="true">https://forum.qt.io/post/137158</guid><dc:creator><![CDATA[chriadam]]></dc:creator><pubDate>Thu, 26 Apr 2012 23:30:44 GMT</pubDate></item><item><title><![CDATA[Reply to [solved]Strange behavior of QML Elements written in Qt on Thu, 26 Apr 2012 13:22:42 GMT]]></title><description><![CDATA[<p dir="auto">Things become even stranger. It looks like the font of timeline 2 is bound to the font of the caption of timeline 1.</p>
<p dir="auto">But how could that be?</p>
]]></description><link>https://forum.qt.io/post/137092</link><guid isPermaLink="true">https://forum.qt.io/post/137092</guid><dc:creator><![CDATA[xardas008]]></dc:creator><pubDate>Thu, 26 Apr 2012 13:22:42 GMT</pubDate></item></channel></rss>