Hello, I wanted to make an app which is when started it shows a menu. It is just like when you open a Messaging app in S60. Here is a screenshot http://bit.ly/jVDiXo.
How do I make it? I have tried to make the centralWidget of the QMainWindow as QMenu, and adding QAction to the QMenu. But when I'm running it, the app don't show anything. And I have tried to make the QMenu using QMenuBar. And it is show okay. But I can't use the up/down key to select menu in the device. And when I press the options key (Qt::PositiveSoftKey), the menubar shows up too. And I didn't even add that to menuBar() which is owned by QMainWindow.
Here is my first code:
QObject::connect(tes,
SIGNAL(triggered
()),
this,
SLOT(close
()));
QObject::connect(tes,
SIGNAL(triggered
()),
this,
SLOT(close
()));
menu->addAction(act1);
menu->addAction(act2);
setCentralWidget(menu);
QAction* act1= new QAction(tr("act1"),this);
QObject::connect(tes,SIGNAL(triggered()),this,SLOT(close()));
QAction* act2= new QAction(tr("act2"),this);
QObject::connect(tes,SIGNAL(triggered()),this,SLOT(close()));
QMenu* menu = new QMenu(this);
menu->addAction(act1);
menu->addAction(act2);
setCentralWidget(menu);
To copy to clipboard, switch view to plain text mode
It shows nothing at the apps.
And here is my second try:
QObject::connect(tes,
SIGNAL(triggered
()),
this,
SLOT(close
()));
QObject::connect(tes,
SIGNAL(triggered
()),
this,
SLOT(close
()));
QMenu* menu
= menubar
->addMenu
(tr
("menu"));
menu->addAction(act1);
menu->addAction(act2);
setCentralWidget(menu);
QAction* act1= new QAction(tr("act1"),this);
QObject::connect(tes,SIGNAL(triggered()),this,SLOT(close()));
QAction* act2= new QAction(tr("act2"),this);
QObject::connect(tes,SIGNAL(triggered()),this,SLOT(close()));
QMenuBar* menubar = new QMenuBar(this);
QMenu* menu = menubar->addMenu(tr("menu"));
menu->addAction(act1);
menu->addAction(act2);
setCentralWidget(menu);
To copy to clipboard, switch view to plain text mode
It shows the menu. But when I deploy to the device, I can't use the keypad to select the menu. And at the simulator, if I click other place than the QAction item, the menu lost.
What is the correct way to do this? Or is my way correct? What should I do next then?
Bookmarks