I test a simple QML(Qt sdk version 5.3.2) program like this
import QtQuick 2.3
import QtQuick.Controls 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
id: appWin
Text {
text: qsTr("Hello World")
anchors.bottom: parent.bottom
}
}
I want the text will be layed on the bottom of application window, that's work. But if I change anchors.bottom: parent.bottom
to anchors.bottom: appWin.bottom
(via id), anchors not work anymore, is this a bug?
This looks like a bug, but it can be by design according following docs:
It's not really clear how we can specify
direct parent
when anchoring. QML translator may only acceptparent
to reference parent qml item.ApplicationWindow
does not ultimately derive fromItem
, so it does not have ananchors
property that's why using the window'sid
does not work. So why does usingparent
? Because the children you define in anApplicationWindow
become children of an intermediateItem
calledcontentItem
: