The Rectangle is not a direct parent or sibling of id something, there's Text in between.
On Wed, Jun 10, 2015 at 4:48 PM, Jason H <jh...@gmx.com> wrote: > I sat down today to teach someone QML and it didn't work as expected. I'm > on Linux usually, this person was on Windows 8, using a 32 bit Mingw. I'm > pretty confident in my QML abilities, now with mobile apps on both App > stores, and many other utilities not published. > > At issue is the simple property of using ids. When using parent, it works, > but anything using the id ("something" in this example) fails. > We tried ApplicationWindow, Window, Rectangle as the root element. When > using the Window, we get "Unable to assign QQuickWindowQmlImpl to > QQuickItem". In all other root elements it fails silently. > > Am I losing my mind? Code below - > > import QtQuick 2.4 > import QtQuick.Controls 1.3 > import QtQuick.Window 2.2 > import QtQuick.Dialogs 1.2 > > Window { > id: something > width: 500; > height: 200 > color: "lightgray" > visible: true > > Text { > id: helloText > text: "Hello world!" > y: 30 > anchors.horizontalCenter: something.horizontalCenter // won't be > horizontally centered unless "parent" > font.pointSize: 24; > font.bold: true > Rectangle{ > anchors.fill:something // won't appeat unless "parent" > color:"red" > > } > } > } > > ----- > Starting > C:\Projects\build-Tutorial-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\Tutorial.exe... > > QML debugging is enabled. Only use this in a safe environment. > > qrc:/main.qml:21:26: Unable to assign QQuickWindowQmlImpl to QQuickItem > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest