QMenu / submenu issues...how to add QAction?
-
I am still not sure how menu and its action relates.
I am adding a new menu into existing
, build by QtDesigner , menu.Thanks to this forum help I can add checked box to submenu attached to the added menu.
I like to add "...->setCheckable(true); to the main , added , menu.
( I will tackle adding check boxes to QDesigner menus later.)But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.
QAction *qAction = m_ui->menuWindow_cpntrol->addAction( "Add TEST submenu" ); //. QMenu* submenuTEST =m_ui->menuWindow_cpntrol->addMenu( "Add TEST memu" ); //submenuTEST->setCheckable(true); QAction* actionTEST_Setup[3]; // = submenuTEST->addAction( "Add TEST submenu" ); for ( int index = 0; index < 3 ; index++) { text = "Add TEST submenu"; text += " index "; text += QString::number(index); actionTEST_Setup[index] = submenuTEST->addAction( text ); actionTEST_Setup[index]->setCheckable(true); }
-
@AnneRanch said in QMenu / submenu issues...how to add QAction?:
I like to add "...->setCheckable(true); to the main , added , menu.
( I will tackle adding check boxes to QDesigner menus later.)There is no need for this. The checkbox appear automatically when you enable
checkable
.But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.
Isn't this what you are doing here?!:
actionTEST_Setup[index] = submenuTEST->addAction( text );
You have your menu (the one created in designer) and your new
submenuTEST
.
After you add yourQActions
to your new menu and add thissubmenuTEST
to your existing menu withaddMenu
If you add actions to a menu and add this menu to another menu, they are all connected