|Home · All Classes · Main Classes · Deprecated|
MeeGo Touch includes a set of layout management classes that are used to describe how widgets are laid out in an application's user interface. These layouts automatically position and resize widgets when the amount of space available for them changes, ensuring that they are consistently arranged and that the user interface as a whole remains usable.
There are two different sets of layout classes.
The second set of layout classes is provided by MeeGo Touch, and offer additional feature, at the cost of slightly more overhead. The MeeGo Touch classes work in a slightly different way - there is a single MLayout to which you can add one or more policies that inherit MAbstractLayoutPolicy. This allows a single layout to have multiple policies, with one active at a given time. A different policy can be made active at any time, causing the items within the layout to move into their new position.
The multiple policies in a single MLayout do not even need to contain the same items. New items will be shown and hidden as necessary (Unless the item is itself a layout, since a layout cannot be directly hidden itself, but a layout inside of a widget inside of a layout will be hidden. See Hiding a QGraphicsLayout or MLayout).
In right-to-left languages, such as arabic, the layouts are automatically reversed. This is usually the correct behavior, however you can override this by directly calling QGraphicsWidget::setLayoutDirection(). For example the calculator example has the following code snippet:
To determine the size of a widget in a layout, the layout uses the widget's QGraphicsLayoutItem::preferredSize() and its QGraphicsLayoutItem::sizePolicy() functions. The preferred size of a MWidgetController is determined from:
The sizes given from the first 3 steps are combined, in the order of preference as shown. If the height and/or width is not specified, then the MWidgetView::sizeHint() function is called, with constraint parameter set to the size determined so far. The result from the view is then combined with the constraint.
If you create your widget and its width depends on its height, then its size policy must have set QSizePolicy::hasHeightForWidth().
Multiple policies can be assigned to a layout. This is particularly useful to have one policy when in portrait mode and another when in landscape mode. For example:
A more concrete example is given with the example calculator program.
For a more complex layout of items, you can place multiple layouts together. This is easiest using a mix of MLayouts and QGraphicsLayout, using a MLayout only when animations and multiple policies are required.
|Copyright © 2010 Nokia Corporation||Generated on Thu Nov 4 2010 18:14:23 (PDT)