Qt Reference Documentation

Maemo 5 Stacked Windows Example

Files:

The Maemo Stacked Windows example shows how to create Maemo 5 "Window Views" with Qt. Technically, Window Views are multiple top-level widgets that can be chained together with a special window attribute. The Maemo 5 window manager will show a sliding animation when switching between the top-level widgets, and the close button will turn into a back arrow to allow the user to go back to the last top-level widget.

Screenshot of the Stacked Windows example

To inform the window manager that the top-level widgets belong to a Window View, all top-levels need to have the Qt::WA_Maemo5StackedWindow attribute set. The parent-child relationship between the top-level widgets determines the stacking order of the Window View.

     QPushButton button1("Click here to open a new stacked window");
     button1.setAttribute(Qt::WA_Maemo5StackedWindow);

A new top-level push button is created, and the Qt::WA_Maemo5StackedWindow attribute is set to inform the Window Manager to treat this top-level button as part of a Window View.

     QPushButton button2("Click here to open another stacked window", &button1);
     button2.setAttribute(Qt::WA_Maemo5StackedWindow);
     button2.setWindowFlags(button2.windowFlags() | Qt::Window);

The second push button is created with the first button as its parent. Again, the Qt::WA_Maemo5StackedWindow attribute is set. Setting a parent widget in Qt implicitly means that the widget is a child widget, so it is necessary to set the Qt::Window window flag to ensure the widget becomes a top-level widget.

     QLabel label("<p align=\"center\">This is the last stacked window. "
                  "Press the back arrow on the top-right corner to go back.",
                  &button2, Qt::Window);
     label.setAttribute(Qt::WA_Maemo5StackedWindow);

Our third and last widget is a label. It gets the second push button as parent widget and the Qt::Window window flag is set to ensure that it is a top-level widget. Again, the Qt::WA_Maemo5StackedWindow attribute is set.

     QObject::connect(&button1, SIGNAL(clicked()), &button2, SLOT(show()));
     QObject::connect(&button2, SIGNAL(clicked()), &label, SLOT(show()));

Finally, the signals are connected. When the first push button is clicked, the second push button is shown. A click on the second push button will show the label.

Qt will handle the hiding of the top-level widgets when the user presses the back arrow.

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); })();