<?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[Qt Quick Controls 2: Same background, multiple buttons]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I got a few buttons and all got the same background. Now in every button there is this code:</p>
<pre><code>background: Rectangle{
    implicitHeight: x;
    implicitWidth: y;
    color: button.pressed ? "lightgray" : "white";
 }
</code></pre>
<p dir="auto">Is it possible, like in Qt Quick Controls, to define a single background rectangle and apply it to all buttons?</p>
]]></description><link>https://forum.qt.io/topic/81666/qt-quick-controls-2-same-background-multiple-buttons</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 08:02:02 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/81666.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Jul 2017 07:50:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt Quick Controls 2: Same background, multiple buttons on Tue, 25 Jul 2017 12:13:52 GMT]]></title><description><![CDATA[<p dir="auto">Thanks to both of you!</p>
]]></description><link>https://forum.qt.io/post/406614</link><guid isPermaLink="true">https://forum.qt.io/post/406614</guid><dc:creator><![CDATA[guy incognito]]></dc:creator><pubDate>Tue, 25 Jul 2017 12:13:52 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Quick Controls 2: Same background, multiple buttons on Tue, 25 Jul 2017 11:39:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy-incognito">@<bdi>guy-incognito</bdi></a> Either what LeLev said, or you can make a custom Button component and reuse that. If there are many customized but identical parts in your buttons it makes sense to customize the whole Button, otherwise it's reasonable to customize only the background.</p>
<p dir="auto">This is actually a very common thing in Controls 2, everything is customized that way. Each type's documentation has also "Customizing X" link.</p>
]]></description><link>https://forum.qt.io/post/406603</link><guid isPermaLink="true">https://forum.qt.io/post/406603</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Tue, 25 Jul 2017 11:39:40 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Quick Controls 2: Same background, multiple buttons on Tue, 25 Jul 2017 09:26:07 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
You just have to create a new reusable file, exemple BackGround.qml (uppercase 'B ' is important to be able to reuse this component)</p>
<p dir="auto">like this :</p>
<p dir="auto"><a href="//Back.qml" target="_blank" rel="noopener noreferrer nofollow ugc">//Back.qml</a><br />
import QtQuick 2.0</p>
<p dir="auto">Rectangle {<br />
color :backMouse.pressed? "red" : "green"<br />
anchors.fill: parent<br />
MouseArea{<br />
id:backMouse<br />
anchors.fill: parent</p>
<pre><code>}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">using :</p>
<p dir="auto">Button{<br />
text: "btn 3"<br />
background: Back{} // Back is our reusable component<br />
}</p>
<p dir="auto">i hope it helps you,</p>
<p dir="auto">LA</p>
]]></description><link>https://forum.qt.io/post/406559</link><guid isPermaLink="true">https://forum.qt.io/post/406559</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Tue, 25 Jul 2017 09:26:07 GMT</pubDate></item></channel></rss>