Function key on symbian non-touch [Solved]
-
Thanks for the link.
I followed it but the buttons doesn't appears.
This is my MainWindow::MainWindow :
@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->menuBar()->addAction("Menu item", this, SLOT(someSlot()));QMenu* m_menu; // Create menu m_menu = new QMenu(this); m_menu->addAction("Menu item", this, SLOT(someSlot())); // Create Options CBA QAction *optionsAction = new QAction("Options", this); // Set defined menu into Options button optionsAction->setMenu(m_menu); optionsAction->setSoftKeyRole(QAction::PositiveSoftKey); addAction(optionsAction); // Create Exit CBA QAction *backSoftKeyAction = new QAction(QString("Exit"), this); backSoftKeyAction->setSoftKeyRole(QAction::NegativeSoftKey); // Exit button closes the application QObject::connect(backSoftKeyAction, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); addAction(backSoftKeyAction); QTextEdit *te; te = new QTextEdit(this); this->setCentralWidget(te);
}
@What's wrong?
Is there a working example to compile for simulator or for my phone ?
-
the button appears in simulator but not in my phone after compiling with remote compiler...
-
Hi Luca,
Due to high interest in this topic I have created a wiki page at Qt DevNet: "How to Add Options Menu in Symbian Application":http://developer.qt.nokia.com/wiki/How_to_Add_Options_Menu_in_Symbian_Application
Please that QMainWindow has predefined Symbian CBA and you do not have to define them again! Your code should look like:
@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
menuBar()->addAction("Menu item", this, SLOT(someSlot()));
}void MainWindow::exampleSlot()
{}
MainWindow::~MainWindow()
{}
@Please also note that the control panel of the application must be enabled. To do it make sure that main.cpp of your application looks like:
@
#include "mainwindow.h"#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);MainWindow mainWindow; mainWindow.showMaximized(); return app.exec();
}
@Cheers,
Leon -
[quote author="leon.anavi" date="1304640197"]
Please that QMainWindow has predefined Symbian CBA and you do not have to define them again!
@
[/quote]How do I define/re-define CBA?
-
Ok, I probably found the problem.
Creating a new mobile project with Qt Creator I get this main:
@
#include "mainwindow.h"#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);MainWindow mainWindow; mainWindow.setOrientation(MainWindow::ScreenOrientationAuto); mainWindow.showExpanded(); return app.exec();
}
@
and showExpanded() is defined as follow:
@
void MainWindow::showExpanded()
{
#ifdef Q_OS_SYMBIAN
showFullScreen();
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
showMaximized();
#else
show();
#endif
}
@
so compiling for Symbian show the application with showFullScreen() .
Showing fullscreen application hide the "exit" button.Can you confirm me this?
-
Hi Luca,
Please stick to the example that I have provided in my previous post and modify your main method. After that modify MainWindow::MainWindow(QWidget *parent) as per my advice and build your application. The Options menu will be visible!
I have tested the example using Qt Creator and the new Qt SDK. It is working on simulator and Nokia E7. I have also tested in using Carbide.C++ and S60v5 simulator the example was working using them too.
Best regards,
Leon -
Ok thanks for your help Leon.
As I can see in your main.cpp you show your MainWindow with:
@
mainWindow.showMaximized();
@and not:
@
mainWindow.showFullScreen();
@That's why I didn't see the button.
Thanks again.
-
[quote author="Luca" date="1304668463"]Ok thanks for your help Leon.
As I can see in your main.cpp you show your MainWindow with:
@
mainWindow.showMaximized();
@
[/quote]Yes, this is an important precondition. I have "added a section about it at our wiki article ":http://developer.qt.nokia.com/wiki/How_to_Add_Options_Menu_in_Symbian_Application#9d86ec4f7dcd920f518cfc5532601cfb
So the issue is solved :)
Cheers,
Leon -
Hi, I'm here again...
Can you see the menu in Qt-Simulator?
I can't.
I see "options" (in the left) and "exit" (in the right). If I press "options" it doesn't show menu while if I press "exit" the application exits. -
Hi, i have the same problem.... I add menu as it in the example and nothing occurs when i press "Options" button. How it could be solved?
Thanks,
Lana -
Hi Luca, Lana,
I have tested Qt Simulator a minute ago and I had the same problem. According to a "thread at Forum Nokia":http://discussion.forum.nokia.com/forum/showthread.php?223306-moved-Why-i-see-my-menu-at-Qt-simulator-control this is the way the simulator works currently. :(
I have never been fan of simulators and this is another proof that is better to work with real device.
Best regards,
Leon -
Hi Leon,
Thanks much, i have already spent a lot of time to try finding the reason of such menu behaviour.
Sincerely,
Lana -
[quote author="leon.anavi" date="1305612824"]Hi Luca, Lana,
I have tested Qt Simulator a minute ago and I had the same problem. According to a "thread at Forum Nokia":http://discussion.forum.nokia.com/forum/showthread.php?223306-moved-Why-i-see-my-menu-at-Qt-simulator-control this is the way the simulator works currently. :(
I have never been fan of simulators and this is another proof that is better to work with real device.
Best regards,
Leon[/quote]
Thanks,
so the Simulator simulate a broken phone... :-)