Home · All Classes · Main Classes · Deprecated |
This is the easiest navigation pattern to implement. Since escapeMode() of a page is by default set to MApplicationPageModel::EscapeAuto, MeeGo Touch either shows a Back button or a Close button when a new page appears, according to the page navigation history (MSceneManager::pageHistory()). When the Back button is clicked, MeeGo Touch automatically dismisses the current page and displays the previous page (in other words, the most recent page in the page navigation history).
To implement this navigation pattern, create the required pages, and MeeGo Touch takes care of the rest.
All files can be found at:
libmeegotouch/examples/pagenavigation_drilldown
main.cpp:
#include <MApplication> #include <MApplicationWindow> #include "samplepage.h" int main(int argc, char **argv) { MApplication app(argc, argv); MApplicationWindow window; SamplePage *page = new SamplePage(1); page->appear(&window); window.show(); return app.exec(); }
samplepage.cpp:
#include "samplepage.h" #include <MSceneManager> #include <MButton> SamplePage::SamplePage(int level) : MApplicationPage(0), level(level) { QString title; if (level == 1) { title = "Root level"; } else { title = QString("Level %1").arg(level); } setTitle(title); QString buttonTitle = QString("Open page level %1").arg(level + 1); MButton *button = new MButton(buttonTitle); connect(button, SIGNAL(clicked()), SLOT(openNextPage())); setCentralWidget(button); } void SamplePage::openNextPage() { SamplePage *nextPage = new SamplePage(level + 1); nextPage->appear(scene(), MSceneWindow::DestroyWhenDismissed); }
samplepage.h:
#ifndef SAMPLEPAGE_H #define SAMPLEPAGE_H #include <MApplicationPage> class SamplePage : public MApplicationPage { Q_OBJECT public: SamplePage(int level); private slots: void openNextPage(); private: int level; }; #endif
Copyright © 2010 Nokia Corporation | MeeGo Touch |