[Qt-qml] Set an item size according to its child?

Alejandro Exojo suy at badopi.org
Thu Jul 14 11:08:21 CEST 2011


Hi.

Imagine that you are grouping several text elements with an item, something 
like this:

import QtQuick 1.0

Item {
    Text {
        id: alarmHour
        text: "09"
        color: "white"; font.pixelSize: 50
        anchors.right: colonSeparator.left; anchors.rightMargin: 30
    }
    Text {
        id: colonSeparator
        text: ":"
        font.pixelSize: 50
        anchors.horizontalCenter: parent.horizontalCenter
    }
    Text {
        id: alarmMinute
        text: "30"
        color: "white"; font.pixelSize: 50
        anchors.left: colonSeparator.right; anchors.leftMargin: 30
    }
}


But now the Item groups everything, but has not size. I can set the height 
with something like "height: colonSeparator.height + 10".

Maybe I'm using the wrong approach? Should I use a Row instead?
Thank you very much.

-- 
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net


More information about the Qt-qml mailing list