<?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[QML : need help so solve a warning]]></title><description><![CDATA[<p dir="auto">Hi!<br />
I'm contributing to the app Mines to learn QML.<br />
I add a timer and a mine counter to tell how many mine left in the minefield.<br />
It's promising, but I have a warning when I launch the app after compiling.<br />
It's about an item Grid inside an item Rectangle (QML speaking).<br />
Here the code :</p>
<pre><code>Grid {
    id: statBar
    width: parent.width
    height: units.gu(20)
    anchors {
        bottom: parent.bottom
    }
    //anchors.fill: parent
    horizontalItemAlignment: Grid.AlignHCenter
    verticalItemAlignment: Grid.AlignVCenter
    columns: 2

    Rectangle {
        id: time_elapsed_rectangle
        height: parent.height
        width: parent.width/2
        anchors {
            left: parent.left
            verticalCenter: parent.verticalCenter
        }

        Row {
            anchors {
                horizontalCenter: parent.horizontalCenter
                verticalCenter: parent.verticalCenter
            }

            Image {
                id: time_icon
                anchors {
                    verticalCenter: parent.verticalCenter
                    margins: units.gu(2)
                }
                source: "../assets/time.svg"
            }
            Rectangle{
                width: units.gu(8)
                height: parent.height
                anchors.verticalCenter: parent.verticalCenter

                Item {
                    Component.onCompleted: reset_timer()
                    Timer {
                        id: timer
                        interval: 500; running: false; repeat: true
                        onTriggered: time.text = minefield.update_time_elapsed()
                    }
                }
                Text {
                    id: time
                    anchors {
                        verticalCenter: parent.verticalCenter
                        horizontalCenter: parent.horizontalCenter
                    }
                }
            }
        }
    }

    Rectangle {
        height: parent.height
        anchors {
            right: parent.right
            left: time_elapsed_rectangle.right
            verticalCenter: parent.verticalCenter
        }

        Row {
            anchors {
                horizontalCenter: parent.horizontalCenter
                verticalCenter: parent.verticalCenter
            }

            Image {
                id: mine_icon
                anchors {
                    verticalCenter: parent.verticalCenter
                    margins: units.gu(2)
                }
                source: "../assets/mine.svg"
            }

            Rectangle{
                width: units.gu(8)
                height: parent.height
                anchors.verticalCenter: parent.verticalCenter

                Text {
                    anchors {
                        verticalCenter: parent.verticalCenter
                        horizontalCenter: parent.horizontalCenter
                    }
                    text: minefield.n_flags + "/" + minefield.n_mines
                }
            }
        }
    }
}
</code></pre>
<p dir="auto">And here my warning :<br />
<code>file:///home/ellypsis/dev/linux_phone/ut_app/Mines/build/tmp/qml/Main.qml:210:13: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.</code><br />
But in fact, the code functions pretty well. But it's not a reason to let a warning in the code.<br />
Any idea?</p>
<p dir="auto">You can find the entire code here : <a href="https://github.com/ellypsis/Mines/tree/timer%26mine_counter" rel="nofollow ugc">Github - ellypsis/Mines</a></p>
]]></description><link>https://forums.ubports.com/topic/1717/qml-need-help-so-solve-a-warning</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 04:27:25 GMT</lastBuildDate><atom:link href="https://forums.ubports.com/topic/1717.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Sep 2018 23:35:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QML : need help so solve a warning on Mon, 01 Oct 2018 22:42:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mymike" aria-label="Profile: mymike">@<bdi>mymike</bdi></a> Thanks! I will keep that in mind for future application <img src="https://forums.ubports.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=eeff4b5fc81" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>https://forums.ubports.com/post/12962</link><guid isPermaLink="true">https://forums.ubports.com/post/12962</guid><dc:creator><![CDATA[Ellypsis]]></dc:creator><pubDate>Mon, 01 Oct 2018 22:42:06 GMT</pubDate></item><item><title><![CDATA[Reply to QML : need help so solve a warning on Mon, 01 Oct 2018 07:52:39 GMT]]></title><description><![CDATA[<p dir="auto">you can't specify <code>anchors</code> for items directly inside the <code>Grid</code>. in your case the <code>Rectangle</code> <code>time_elapsed_rectangle</code> has <code>anchors</code> but you have to delete them</p>
]]></description><link>https://forums.ubports.com/post/12923</link><guid isPermaLink="true">https://forums.ubports.com/post/12923</guid><dc:creator><![CDATA[mymike]]></dc:creator><pubDate>Mon, 01 Oct 2018 07:52:39 GMT</pubDate></item><item><title><![CDATA[Reply to QML : need help so solve a warning on Sun, 30 Sep 2018 16:44:18 GMT]]></title><description><![CDATA[<p dir="auto">I did a work around. I replaced my Grid layout to a rectangle layout.<br />
Maybe it's a bit dirty, but it works fine.<br />
New code here : <a href="https://github.com/ellypsis/Mines/tree/timer%26mine_counter" rel="nofollow ugc">https://github.com/ellypsis/Mines/tree/timer%26mine_counter</a></p>
]]></description><link>https://forums.ubports.com/post/12908</link><guid isPermaLink="true">https://forums.ubports.com/post/12908</guid><dc:creator><![CDATA[Ellypsis]]></dc:creator><pubDate>Sun, 30 Sep 2018 16:44:18 GMT</pubDate></item></channel></rss>