[Qt-qml] Prperty-binding to parent

Almo Nito AlmoNito at gmx.de
Thu Sep 23 22:32:42 CEST 2010


Hello There, i have soime difficulies in udnerstanding how to communicate
with the upper layer!

 

 

 

 

I Have a top player containing the following elements:

 

ctxt->setContextProperty("CommObject",_COMM);

 

    Ressources.Volume {

 

            id:vol

            value:CommObject.Volume

 

            height:120

            width:400;

 

            x:background.width/2-vol.width/2

            y:background.height/2-vol.height/2

 

        }

 

 

 

 

import Qt 4.7

 

import "Slider.qml"

 

Item {

    id: volume

 

    property int value:slider.value

 

 

    Rectangle {

        x:0

        y:0

       border.color:"#9b9b9b"

        border.width:2

        color: "#454545"

        radius:20

        opacity:0.7;

        width:parent.width

        height:parent.height

    }

 

    Slider {

        id: slider

        x:30

        y:parent.height-slider.height -30

        width: parent.width-60

        height:parent.height/3

 

    }

 

    Text {

        id: text

        text: "Volume:"

        y:slider.y -text.height-10

        x:slider.x

        font.pointSize:17

        color: "#e1e1e1"

    }

 

    Text {

        id: textvalue

        text: slider.value+"%"

        y:slider.y -text.height-10

        x:text.x+text.width +10

        font.pointSize:17

        color: "#e1e1e1"

    }

 

 

 

}

 

 

And Finally:

 

 

import Qt 4.7

 

Rectangle {

    id: rslider;

    width: parent.width;

    height: parent.height;

    property int value:
Math.round(handle.x*100/(rslider.width-handle.width))

 

    onValueChanged: {

 

        console.log("Yo, sup")

 

    }

 

 

 

    gradient: Gradient {

            GradientStop { position: 0.0; color: "#d6d6d6" }

            GradientStop { position: 0.3; color: "#efeded" }

            GradientStop { position: 0.6; color: "#dedddd" }

            GradientStop { position: 0.8; color: "#efeded" }

            GradientStop { position: 1.0; color: "#eae9e9" }

        }

 

 

    radius:5

    border.color: "grey"

    border.width:1

 

 

    Rectangle {

        id: fill

        x:1

        y:1

        width:handle.x+5

 

        gradient: Gradient {

                GradientStop { position: 0.0; color: "#f75100" }

                GradientStop { position: 0.3; color: "#e24c02" }

                GradientStop { position: 0.6; color: "#e26b02" }

                GradientStop { position: 0.8; color: "#ce5504" }

                GradientStop { position: 1.0; color: "#b74a01" }

            }

 

        height:slider.height-2

        radius:slider.radius

 

    }

 

    Rectangle {

        id: handle;

        y:-2

        width: parent.width/6;

        height: parent.height+4

 

 

        gradient: Gradient {

                GradientStop { position: 0.0; color: "#b5b5b5" }

                GradientStop { position: 0.3; color: "#ababab" }

                GradientStop { position: 0.6; color: "#b3b1b1" }

               GradientStop { position: 0.8; color: "#a6a6a6" }

                GradientStop { position: 1.0; color: "#b5b5b5" }

            }

 

 

 

        radius:5

        border.color:"#6e6e6e"

        border.width:1

 

        MouseArea {

            anchors.fill: parent

            drag.target: parent;

            drag.axis: "XAxis"

            drag.minimumX: 0;

            drag.maximumX: slider.width - handle.width

        }

    }

}

 

 

 

Now the onValueChanged in the Slider itself works fine, but as soon as I
place the onValueChanged in the

Item {

    id: volume

 

which is also supposed to hold the same value property by a binding (as I
understood) it don't work anymore, now I would like to kno 2 things:

 

how to do I set a childs property by a parent, and how to I pass a child
property to a upper parent

 

Thanks ALOT

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100923/e1cb4f36/attachment.html 


More information about the Qt-qml mailing list