[Qt-qml] Non-QML elements in Row or Column

Tapani Mikola tapani.mikola at nokia.com
Thu Apr 22 17:57:16 CEST 2010


One solution I have found is to make a QML component and wrap the QGW into a QML Item. And then in Component.onCompleted set the width & height to preferredSize.width & .height. Also some kind of 'polish' call might be needed, if the widgets use late layouting & size calculation in polish event handler and not calculate their sizeHints after setting each relevant property.

Something like this in your Widget.qml:

import Qt 4.7
import MyGraphicsWidgets

Item {
    id: wrapper
    property alias text: hbwidget.text

    MyWidget {
        id: mywidget
        text: ""
        x: 0; y: 0
        width: wrapper.width; height: wrapper.height
    }

    Component.onCompleted: {
        mywidget.polish () // To calculate the preferredSize
        width = mywidget.preferredSize.width;
        height = mywidget.preferredSize.height;
    }
}


Another solution is to set the height (if one is inside Column) or width (in Row) explicitly. Then no wrapper component is needed.

- Tapani

On Thursday 22 April 2010 16:21:33 Kellomaki Pertti (Nokia-D/Tampere) wrote:
> I am trying to put non-QML widgets inside a Column, but all the widgets 
> get drawn on top of each other. What does an element need to understand 
> ori provide in order to be positioned by a Column?
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100422/d8b3177f/attachment.html 


More information about the Qt-qml mailing list