[Qt-qml] Why can't I anchor to parent

Juha Turunen turunen at iki.fi
Tue Jul 13 03:30:53 CEST 2010


You anchor to a parent like this:

anchors.top: parent.top

Check out the documentation here:
http://doc.qt.nokia.com/4.7-snapshot/anchor-layout.html


On Tue, Jul 13, 2010 at 2:46 AM, Jason H <scorp1us at yahoo.com> wrote:

> Hi again. I am trying to anchor to parent
> |A    |
> |    B|
> |C    |
>
> With the rect being the parent. But I get the message: "QML Text: Cannot
> anchor
> to a null item."
>
>
> importQt4.7
> Rectangle {
>        width: 1024
>        height:768
>        gradient: Gradient {
>                GradientStop { position: 0; color: "Navy"}
>                GradientStop { position: 1; color: "Black"}
>        }
>        //Font { id: third; family: "NiteClub"; pointSize:30; color:
> "White"}
>        Text {
>                text: "A";  font.family: "NiteClub"; font.pointSize:30;
> color: "White";
>                anchors.top:parent.anchors.top;
>                anchors.left: parent.anchors.left
>        }
>        Text {
>                text: "B";  font.family: "NiteClub"; font.pointSize:30;
> color: "White";
>                anchors.verticalCenter:parent.anchors.verticalCenter;
>                anchors.right:parent.anchors.right
>        }
>        Text {
>                text: "C";  font.family: "NiteClub"; font.pointSize:30;
> color: "White";
>                anchors.bottom:parent.anchors.bottom;
>                anchors.left:parent.anchors.left
>        }
> }
>
>
>
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-qml
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100713/13b1875d/attachment.html 


More information about the Qt-qml mailing list