<?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[Image size in Item component]]></title><description><![CDATA[<p dir="auto">Hi<br />
I want to fix the size of an image within an item and have a taller rectangle to the right of it.</p>
<p dir="auto">Here is the declaration of my component</p>
<pre><code>import QtQuick 2.9
import QtQuick.Controls 2.5

Item {
    id: button
    width: 100
    height: 200
    signal clicked

Image {
    id: backgroundImage
    anchors.fill: parent
    source: (button.enabled ? "images/simulation.png" : "images/simulation.png")
    width: 100
    height: 100
}

Rectangle {
    color: "#22add8"
    anchors.left: backgroundImage.right
    anchors.leftMargin: 10
    width: 5
    height: 200
}

//Mouse area to react on click events
MouseArea {
    anchors.fill: button
    onClicked: {
        console.log("clicked")
        button.clicked()
    }
    onPressed: {
        console.log("pressed")
        backgroundImage.source = "images/simulation.png" }
    onReleased: {
        console.log("released")
        backgroundImage.source = (button.enabled ? "images/simulation.png" : "images/simulation.png")
    }
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">The image always takes the height of the item</p>
<p dir="auto">How can I fix the size of the image?</p>
]]></description><link>https://forum.qt.io/topic/101436/image-size-in-item-component</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 20:28:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/101436.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Apr 2019 15:00:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Image size in Item component on Mon, 08 Apr 2019 07:47:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/shrinidhi-upadhyaya">@<bdi>Shrinidhi-Upadhyaya</bdi></a><br />
Thanks</p>
]]></description><link>https://forum.qt.io/post/521810</link><guid isPermaLink="true">https://forum.qt.io/post/521810</guid><dc:creator><![CDATA[GrahamLa]]></dc:creator><pubDate>Mon, 08 Apr 2019 07:47:05 GMT</pubDate></item><item><title><![CDATA[Reply to Image size in Item component on Mon, 08 Apr 2019 06:41:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/grahamla">@<bdi>GrahamLa</bdi></a> ,make these changes to the code:-</p>
<pre><code> Image {
        id: backgroundImage
        
        //####Remove the below line,you are assigning the height and width of the parent.
        //            anchors.fill: parent
        source: (button.enabled ? "images/simulation.png" : "images/simulation.png")
        width: 100
        height: 100
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/521796</link><guid isPermaLink="true">https://forum.qt.io/post/521796</guid><dc:creator><![CDATA[Shrinidhi Upadhyaya]]></dc:creator><pubDate>Mon, 08 Apr 2019 06:41:12 GMT</pubDate></item></channel></rss>