title: how to add menu dynamically in Qt
body: <p>I want to add, submenu to a menu item dynamically. How can I achive this?</p>
  
  <p>I tried like this,
  I have created an  Action and submenu. Then I have added the submenu to action. 
  But, I have connected the “triggered” signal of action. its getting crash if I click on the action..</p>
  
  <p>I have also handled the “aboutToShow” signal of menu, same its also getting crash when I click on action..</p>
  
  <p>Here is the sampe code.</p>
  
  <pre><code>Submenu = new QMenu(this);      
  connect(Submenu, SIGNAL( aboutToShow()), this, SLOT(move ()));
  
                    QAction *test = new QAction(tr("Selection"), this);
                    test -&gt;setMenu(Submenu);
  
                   menubar()-&gt;addAction(test);
  </code></pre>
  
  <p>I want to get the notification, before the display of submenu..</p>
  
  <p><strong><em>additonal information:</em></strong></p>
  
  <p>pleas try this code, in your main window constructor.</p>
  
  <pre><code>QAction *action = new QAction("Test",this);
  QAction *dummyaction = new QAction("Testing",this);
  QMenu *menu = new QMenu();
  menu-&gt;addAction(dummyaction);
  
  bool val= connect(menu, SIGNAL( aboutToShow()), this, SLOT( Move()));
  val= connect(menu, SIGNAL( aboutToHide()), this, SLOT(Move()));
  
  action-&gt;setMenu(menu);
  this-&gt;menuBar()-&gt;addAction(action);
  </code></pre>
  
  <p>if I do like this, I am able to see one submenu item. But before that Move slot should call, its not getting called.. and even before hide also the same slot should call.. its not coming..</p>
  
  <p>I tried the return values of connect.. its true only… so what is wrong with my code.. please say..</p>