| 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 first is provided by Qt, and inherit from QGraphicsLayout, including QGraphicsLinearLayout, QGraphicsGridLayout, etc. These Qt classes provide an easy way to layout items as you want.
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:
CalculatorWidget::CalculatorWidget()
{
mValue = 0;
//Prevent the layout from changing in right-to-left.
//The calculation line will still be reversed however.
setLayoutDirection(Qt::LeftToRight);
/* Create a MLayout attached to this widget */
MLayout *layout = new MLayout(this);
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.
Finally, if this size is still not valid, the size is combined with QGraphicsWidget::sizeHint() which in turn uses the layout's QGraphicsLayoutItem::sizeHint() function.
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.
For example using multiple QGraphicsLinearLayouts we can obtain a layout where items are laid in rows, but the items do not line up vertically. For example:
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:14:23 (PDT) Doxygen 1.7.1 |
MeeGo Touch |