How to add Option menus in Mobility Project?
I have generated a std Mobility Project with a QMainWindow base. Have added code for the menu's
However clicking the option (left) button in an any of the emulators (Maemo, Symbian Touch/Non-Touch) shows nothing.
Suggestions?
Thanks - Lindsay
[CODE]void MainWindow::setupGeneral()
{
deviceInfo = new QSystemDeviceInfo(this);
ui->batteryLevelBar->setValue(deviceInfo->batteryLevel());
connect(deviceInfo, SIGNAL(batteryLevelChanged(int)),
ui->batteryLevelBar, SLOT(setValue(int)));
// Options Menu
QAction *actTest1 = new QAction(tr("Test Item 1"), this);
menuBar()->addAction(actTest1);
connect(actTest1, SIGNAL(triggered()), this, SLOT(test1()));
QAction *actTest2 = new QAction(tr("Test Item 2"), this);
menuBar()->addAction(actTest2);
connect(actTest2, SIGNAL(triggered()), this, SLOT(test1()));
}[/CODE]
Re: How to add Option menus in Mobility Project?
This is how menu is created on Maemo
[url]http://doc.qt.nokia.com/qt-maemo-4.6/maemo5-menu.html[/url]
In future I suggest you to choose more meaningful thread titles as current one distract people from reading the actual thread.
Re: How to add Option menus in Mobility Project?
Eh?
1 - How is my title not meaningful?! Its states exactly what I want to know!
2 - Did you actually read my message? The code snippet I posted does exactly what the one you linked to does. Probably because I searched the forum for examples to try first before asking.
Re: How to add Option menus in Mobility Project?
The title's not meaningful because (A) this has nothing to do with Mobility, and (B) you're dealing with Maemo and should be in the Maemo folder.
On a separate note, ALWAYS capture and test (with Q_ASSERT) the result from connect(). Can save you hours of debugging time.
Re: How to add Option menus in Mobility Project?
[QUOTE=danhicksbyron;760700](B) you're dealing with Maemo and should be in the Maemo folder.[/QUOTE]
It was mention of Maemo and Symbian in the original post that's why it was moved from Qt Mobility project to Qt General. I believe there is no significant difference between creation of menus in Maemo and Symbian.
Re: How to add Option menus in Mobility Project?
Nothing to do with mobility? its a mobility project! being tested in the mobility emulators and a real symbian (N95) device. I'm well aware of how menus are added/managed in Qt. The problem is the code for menus I got via the forums is supposed to appear on using the "Select" or "Options" key, but its *doesn't*, not in the Maemo or Symbian emulators or on a real Nokia phone.
Hence it being a *Mobility* problem. I presuming I'm doing something wrong and I'd appreciate a pointer as to how to attach menus to the select key as I made perfectly clear in my thread title rather than snarky comments.
Re: How to add Option menus in Mobility Project?
It cannot be related to Qt Mobility. There are amount of successful applications using Qt Mobility and having menus. Search in your code for another reason for this behaviour or present us a small test application demonstrating how Qt Mobility can prevent menus from appearing.
Re: How to add Option menus in Mobility Project?
Problem solved mostly.
Mainly it was because I assumed to much of the symbian emulator - I presumed it would actually emulate the soft key behavour of an actual device, but it doesn't, the menus appear in the qt controller beside it. Additionally unless you add them to a menu bar (which has to be created for QDialog) they won't appear at all.
Also it took quite a bit of digging to find the QAction::setSoftKeyRole(QAction::PositiveSoftKey); call plus all the examples I could find where for Qt 4.5, QT 4.6 has changed that API considerably.
Following is a code snippet which works as I wanted - i.e attach menus to the Left and Right soft keys and set the titles for them. Note it takes a conditional compile to work in the emulator plus the emulators doesn't set the soft key titles.
[CODE]
void BatteryIndicator::addSoftKeys()
{
///////////////////////////////////////////////////////
// Options Menu
QAction* options = new QAction(tr("Test Select"), this);
QMenu *menuOptions = new QMenu(this);
menuOptions->addAction(tr("Test 1"), this, SLOT(Test1()));
menuOptions->addAction(tr("Test 2"), this, SLOT(Test2()));
options->setMenu(menuOptions);
///////////////////////////////////////////////////////
// Exit Action
QAction* exit = new QAction(tr("Test Exit"), this);
connect(exit, SIGNAL(triggered()), this, SLOT(QuitApp()));
#if defined(Q_OS_SYMBIAN)
// Set Soft Key locations
// QAction::PositiveSoftKey = Left Soft Key
// This will set the left soft key menu
options->setSoftKeyRole(QAction::PositiveSoftKey);
exit->setSoftKeyRole(QAction::NegativeSoftKey);
// Add Actions Direct to dialog
// QAction::NegativeSoftKey = Right Soft Key
// This will set the right softkey caption and action
addAction(options);
addAction(exit);
#else
// Create Menu Bar for the QDialog and add to that
// Note:If you did this under symbian all the menus would be a sub menu of the
// Left Soft Key
QMenuBar *menuBar = new QMenuBar(this);
layout()->setMenuBar(menuBar);
menuBar->addAction(options);
menuBar->addAction(exit);
#endif
}
[/CODE]
Re: How to add Option menus in Mobility Project?
As I know, the qt simulator in NokiaQtSDK is bad one. The options and exit are pictures in the simulator, not the real menu . And you can see if the menu appears on the "Applications" tab on the qt simulator WIndow.
Re: How to add Option menus in Mobility Project?
Hi. I have a same problem. No action in softkey in Qt Simulator.
I also tried to activate softkey using your code snippet but there is no different.
Does it only works in the real device?
Please explain to me more detailedly.
Re: How to add Option menus in Mobility Project?
Yes, softkeys are working properly on real devices and simulator. You are supposed to use Qt 4.6.3 or 4.7 preview.