January 23, 2011

Lampros Giampouras Lampros Giampouras
Lab Rat
17 posts

Creating a menu

 

I’m trying to create a menu, so I tried this.

  1.     ui->setupUi(this);
  2.  
  3.     //Creating actions
  4.     insert = new QAction(tr("Insert"),this);
  5.     connect(insert, SIGNAL(triggered()), this, SLOT(on_InsertButton_clicked()));
  6.     detect = new QAction(tr("Check"),this);
  7.     connect(detect, SIGNAL(triggered()), this, SLOT(on_DetectButton_clicked()));
  8.     about = new QAction(tr("About"),this);
  9.     connect(about, SIGNAL(triggered()), this, SLOT(on_AboutPushButton_clicked()));
  10.  
  11.     //Creating menu
  12.     eyemenu = new QMenu("Options", this);
  13.     eyemenu->addAction(insert);
  14.     eyemenu->addAction(detect);
  15.     eyemenu->addSeparator();
  16.     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.

8 replies

January 23, 2011

Milot Shala Milot Shala
Lab Rat
393 posts

If you are using a QMainWindow you should use a menuBar() variable in order to add the menu there like:

  1. ui->menubar->addMenu(eyemenu);

January 24, 2011

Mattias Cibien Mattias Cibien
Lab Rat
66 posts

if you wish to add a popup menu yuo can do something like this

  1. void ListWidget::customContentsMenu( const QPoint &pos )
  2. {
  3.     QPoint globalPos = this->mapToGlobal(pos);
  4.     menu->exec( globalPos );
  5. }

 Signature 

http://mattias-cibien.co.cc
- Prepare for Qt consequences.

January 24, 2011

Lampros Giampouras Lampros Giampouras
Lab Rat
17 posts

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

January 24, 2011

Milot Shala Milot Shala
Lab Rat
393 posts

I don’t know if it’s a bug or a feature but the steps for removing the actions option are:

  1. Go to the Qt Designer (you can do this in the code as well)
  2. Select every Widget in your form
  3. 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).
  4. See the screenshot below

pic

January 25, 2011

Lampros Giampouras Lampros Giampouras
Lab Rat
17 posts

Thanks, actions option is gone. :)

January 25, 2011

Milot Shala Milot Shala
Lab Rat
393 posts

I probably have to write a wiki article on how to remove the strange actions menu.

January 27, 2011

Mattias Cibien Mattias Cibien
Lab Rat
66 posts

Milot Shala wrote:
I don’t know if it’s a bug or a feature but the steps for removing the actions option are:

  1. Go to the Qt Designer (you can do this in the code as well)
  2. Select every Widget in your form
  3. 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).
  4. See the screenshot below

!http://i.imgur.com/07z8J.png(pic)!

That’s great :)

 Signature 

http://mattias-cibien.co.cc
- Prepare for Qt consequences.

January 27, 2011

Milot Shala Milot Shala
Lab Rat
393 posts

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 [developer.qt.nokia.com]

 
  ‹‹ [Repost from QtQuick] Loading Sqlite database within the project directory      problem with the framebuffer on an ARM device ››

You must log in to post a reply. Not a member yet? Register here!