How to Add Options Menu in Symbian Application: Difference between revisions
AutoSpider (talk | contribs) (Convert ExpressionEngine section headers) |
AutoSpider (talk | contribs) (Mark Outdated: Symbian no longer supported) |
||
Line 1: | Line 1: | ||
{{Outdated|reason=The Symbian platform is no longer supported.}} | |||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
Revision as of 15:17, 19 March 2015
IMPORTANT: The content of this page is outdated. Reason: The Symbian platform is no longer supported. If you have checked or updated this page and found the content to be suitable, please remove this notice. |
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
English Български
[toc align_right="yes" depth="2"]
How to Add Options Menu in Symbian Application
Options menu and Exit button can be attached to QMainWindow, QDialog or to QWidget on Symbian. QMainWindow has predefined Symbian CBA buttons but they have to be defined for QDialog and QWidget.
Preconditions
Make sure that the status pane and the control pane of the application are enabled. To do it call method showMaximized() of the main window:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.showMaximized();
return app.exec();
}
QMainWindow has predefined Symbian CBA buttons so different options can be added to the Options menu by adding a new action.
menuBar()->addAction("Example", this, SLOT (exampleSlot())); <code>
Please note that '''exampleSlot()''' slot is called when an item is selected from the Options menu and its behavior should be also implemented.
== Defining menus in QDialog or QWidget ==
Symbian CBA buttons are not predefined for QDialog or QWidget and they have to be defined.
An instance of [http://doc.qt.nokia.com/latest/qmenu.html QMenu] should be added at the header:
QMenu* m_pMenu;
At appropriate location should be added the implementation of Options menu and the Exit button:
// Create menu
m_pMenu = new QMenu(this);
m_pMenu->addAction("Example", this, SLOT (exampleSlot()));
// Create Options CBA
QAction *pOptions = new QAction("Options", this);
// Set defined menu into Options button
pOptions->setMenu(m_pMenu);
pOptions->setSoftKeyRole(QAction::PositiveSoftKey);
addAction(pOptions);
// Create Exit CBA
QAction *pExitButton = new QAction(QString("Exit"), this);
pExitButton->setSoftKeyRole(QAction::NegativeSoftKey);
// Exit button closes the application
QObject::connect(pExitButton, SIGNAL (triggered()),
QApplication::instance(), SLOT (quit()));
addAction(pExitButton);
Of course the right button can be used not only to close the application as it can be connected to other slot.
See also
[http://developer.qt.nokia.com/wiki/Remove_actions_options_menu_in_Symbian Remove actions option menu in Symbian ]