May 26, 2011

gogoi gogoi
Lab Rat
58 posts

Menu Problems

 

hello friends

Actually i am not able to contruct a menu in my App..the code i have written is like that…

  1. #include "menumainwindow.h"
  2.  
  3. menumainwindow::menumainwindow(QWidget *parent)
  4.     : QMainWindow(parent)
  5. {
  6.  
  7.  
  8.  showAct = new QAction(("&Show"), this);
  9.  connect(showAct, SIGNAL(triggered()),label1, SLOT(show()));
  10.  hideAct = new QAction(("&Hide"), this);
  11.  connect(hideAct, SIGNAL(triggered()),label1, SLOT(hide()));
  12.  exitAct = new QAction(("&Exit"), this);
  13.  connect(exitAct, SIGNAL(triggered()),qApp, SLOT(quit()));
  14.  bar = menuBar()->addMenu("&File");
  15.  bar->addAction(showAct);
  16.  bar->addAction(hideAct);
  17.  bar->addSeparator();
  18.  bar->addAction(exitAct);
  19.         setCentralWidget(bar);
  20.  
  21. }

here it will display show,hide,exit menu but i want it to show when i click the “file”..so anything wrong in the code..please suggest

regards
Rahul

5 replies

May 26, 2011

cincirin cincirin
Ant Farmer
387 posts

remove setCentralWidget(bar), or set other central widget in your main window

May 26, 2011

gogoi gogoi
Lab Rat
58 posts

hello cincirin

but if i remove setcentralWidget(bar) than nothing diaplay in the simulator..

May 26, 2011

cincirin cincirin
Ant Farmer
387 posts

hi !
First thing, sorry, I didn’t realize that this is mobile forum.
Now, if you set other central widget in your main window, other than menu bar, didn’t work ?

May 26, 2011

gogoi gogoi
Lab Rat
58 posts

i cant get it can you please me how that can be done..can you give me an example of hoe it can be done

May 26, 2011

cincirin cincirin
Ant Farmer
387 posts

  1. setCentralWidget(new QWidget)

 
  ‹‹ Date functions problem      problem with Qjson ››

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