Qt Reference Documentation

Maemo 5 Menu Example

Files:

The Maemo 5 Menu example shows how to create a menu for a Maemo 5 device.

The Maemo 5 UI style guide describes a menu that looks very different from the menus on other targets. The buttons are big to allow finger selection and no sub-menus are allowed. Please read the documentation on maemo.org for further information.

Actions can be added to widgets via QWidget::addAction() but for Maemo 5 they should be added directly to the menu bar instead. The example shows how to do this:

         menuBar()->addAction(tr("Action 1"));
         menuBar()->addAction(tr("Action 2"));
         menuBar()->addAction(tr("Action 3"));

The Maemo 5 menus allow so called filters. Those are buttons intended to switch the main ui screen between different views. Those buttons can be displayed via an exclusive QActionGroup with checkable actions:

         QActionGroup *filterGroup = new QActionGroup(this);
         filterGroup->setExclusive(true);

         QAction *actEnable = new QAction(tr("Enabled"), filterGroup);
         actEnable->setCheckable(true);
         actEnable->setChecked(true);

         QAction *actDisable = new QAction(tr("Disabled"), filterGroup);
         actDisable->setCheckable(true);

         QAction *actWhatever = new QAction(tr("Whatever"), filterGroup);
         actWhatever->setCheckable(true);

         menuBar()->addActions(filterGroup->actions());

Simple checkable actions are also supported by Qt even though the Maemo 5 style guide does not mention them:

         QAction *checkAction = new QAction(tr("Checkable"), this);
         checkAction->setCheckable(true);
         menuBar()->addAction(checkAction);

As with normal menus you can also use a QWidgetAction to add widgets to the menu. This is expecially useful for the QMaemo5ValueButton. The example demonstates this by subclassing QWidgetAction to create a PickSelectorAction class that returns a QMaemo5ValueButton when its createWidget() method is called:

         menuBar()->addAction(new PickSelectorAction(this));
X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();