Creating a menu
-
wrote on 23 Jan 2011, 10:32 last edited by
I'm trying to create a menu, so I tried this.
@
ui->setupUi(this);//Creating actions insert = new QAction(tr("Insert"),this); connect(insert, SIGNAL(triggered()), this, SLOT(on_InsertButton_clicked())); detect = new QAction(tr("Check"),this); connect(detect, SIGNAL(triggered()), this, SLOT(on_DetectButton_clicked())); about = new QAction(tr("About"),this); connect(about, SIGNAL(triggered()), this, SLOT(on_AboutPushButton_clicked())); //Creating menu eyemenu = new QMenu("Options", this); eyemenu->addAction(insert); eyemenu->addAction(detect); eyemenu->addSeparator(); eyemenu->addAction(about);
@
But, nothing show up on the left side of the menu on Symbian. Just the right 'Exit' button.
Is there any mistake on this? Thanks. -
wrote on 23 Jan 2011, 11:06 last edited by
If you are using a QMainWindow you should use a menuBar() variable in order to add the menu there like:
@
ui->menubar->addMenu(eyemenu);
@ -
wrote on 24 Jan 2011, 15:22 last edited by
if you wish to add a popup menu yuo can do something like this
@
void ListWidget::customContentsMenu( const QPoint &pos )
{
QPoint globalPos = this->mapToGlobal(pos);
menu->exec( globalPos );
}
@ -
wrote on 24 Jan 2011, 19:21 last edited by
Thanks,
I created a menubar with Qt creator's UI. It seems to be working ok, but I also get an "actions" option when I run it on the phone (which does nothing). No idea what that is :o
-
wrote on 24 Jan 2011, 20:29 last edited by
I don't know if it's a bug or a feature but the steps for removing the actions option are:
Go to the Qt Designer (you can do this in the code as well)
Select every Widget in your form
In the properties pane find contextMenuPolicy and change it to NoContextMenu for every widget inside your form (could be a QWidget, QDialog or a QMainWindow).
See the screenshot below
-
wrote on 25 Jan 2011, 10:17 last edited by
Thanks, actions option is gone. :)
-
wrote on 25 Jan 2011, 10:59 last edited by
I probably have to write a wiki article on how to remove the strange actions menu.
-
wrote on 27 Jan 2011, 07:57 last edited by
[quote author="Milot Shala" date="1295900993"]I don't know if it's a bug or a feature but the steps for removing the actions option are:
Go to the Qt Designer (you can do this in the code as well)
Select every Widget in your form
In the properties pane find contextMenuPolicy and change it to NoContextMenu for every widget inside your form (could be a QWidget, QDialog or a QMainWindow).
See the screenshot below
!http://i.imgur.com/07z8J.png(pic)![/quote]
That's great :)
-
wrote on 27 Jan 2011, 09:37 last edited by
We have also a wiki page for this. I will improve it in the near future: "http://developer.qt.nokia.com/wiki/Remove_actions_options_menu_in_Symbian":http://developer.qt.nokia.com/wiki/Remove_actions_options_menu_in_Symbian
1/9