[Interest] What about this simple QML is broken?

Jérôme Godbout jerome at bodycad.com
Wed Jun 10 22:52:57 CEST 2015


http://doc.qt.io/qt-5/qtquick-positioning-anchors.html#restrictions
For references

On Wed, Jun 10, 2015 at 4:52 PM, Jérôme Godbout <jerome at bodycad.com> wrote:

> 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 <jhihn at 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 at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150610/16cd63ee/attachment.html>


More information about the Interest mailing list