<?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[ImplicitWidth of RowLayout strange behavior when resizing layouts]]></title><description><![CDATA[<p dir="auto">Hi, I am using QtQuick.Layouts to make a camera surveillance software where the software shows different numbers of camera viewports such as 3x4 and 3x6 by clicking the 3x4 or 3x6 buttons. Each viewport has a Rowlayout component. I found the implicitWidth of RowLayout has a larger value in a smaller layout (3x6)  than in a larger layout(3x4) (ApplicationWindow size is the same), whereas the width of RowLayout is consistent with the layout size (larger layout has larger width). I need to compare "implicitWidth" with "width" of Rowlayout in order to re-arrange items in each camera view. The strange behavior of implicitWidth prevents me from re-arranging items correctly. How is implicitWidth calculated? How to correctly use implicitWidth to compare with width?</p>
<p dir="auto">The code is below. The contents in ToolButtons and Texts components were omitted for simplicity.</p>
<pre><code>ApplicationWindow {
    id: appWindow
    visible: true

    width: 1600
    height: 900

    minimumWidth: 1200
    Rectangle {
        id: mainForm
        width: 1280
        height: 720
        border.width: 5
        color: "black"
        focus: true
        GridLayout {
                id: gridMain
                columnSpacing: 2
                rowSpacing: 2
                anchors.rightMargin: 3
                anchors.leftMargin: 3
                anchors.bottomMargin: 3
                anchors.topMargin: 3
                anchors.fill: parent

                rows: 3
                columns: 6
              // e.g. repeat 3x6 the following Rectangles to fill the gridlayout. 

                Rectangle {
                    id: root
                    color: "black"
                    border.width: 3
                    border.color: "green"
                    Layout.fillHeight: true,
                    Layout.fillWidth : true,
                    Layout.row: gridHelper(i, true),
                    Layout.column: gridHelper(i, false),
                    visible: true,
                    cameraName: "None",
                    room: "",
                    viewId : i,
                    Layout.minimumWidth: rowLayout.Layout.minimumWidth + 2 * margin
                    Layout.minimumHeight: rowLayout.Layout.minimumHeight + 2* margin
                    property int margin: 11

                    ColumnLayout {
                        id: columnLayout

                        anchors.rightMargin: 3
                        anchors.leftMargin: 3
                        anchors.bottomMargin: 3
                        anchors.topMargin: 3
                        anchors.fill: parent
                        anchors.margins: 1
                        Layout.fillWidth: true
                        objectName: "colLayout"

                        ToolBar {
                            id: toolBar
                            opacity: 1
                            Layout.fillHeight: false
                            Layout.fillWidth: true

                            background: Rectangle{
                                color: "black"
                            }

                            RowLayout {
                                id: rowLayout
                                Layout.minimumWidth: 150
                                anchors.fill: parent
                                anchors.margins: 2
                                    ToolButton{}
                                    ToolButton{}
                                    Text {}
                                    Text {}
                                    Item{}
                                    Text {}
                            }
                        }
                    }
                }
        }
    }
}

</code></pre>
]]></description><link>https://forum.qt.io/topic/145955/implicitwidth-of-rowlayout-strange-behavior-when-resizing-layouts</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 04:44:02 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145955.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Jun 2023 21:09:10 GMT</pubDate><ttl>60</ttl></channel></rss>