```c QMenu* mainMenu; QAction* action1 = mainMenu->addAction(QIcon(":/icon1.png"),"Entry1" ); connect( action1, &QAction::triggered, this, &MyClasss::mySlot1, Qt::UniqueConnection ); QAction* action2 = mainMenu->addAction(QIcon(":/icon2.png"), "Entry2" ); connect( action2, &QAction::triggered, this, &MyClasss::mySlot2, Qt::UniqueConnection ); // --- SUBMENU -------------------------------------------------------- QMenu* subMenu = mainMenu->addMenu( QIcon(":/menuIcon.png"), "SubMenu Title" ); QAction* subAction1 = mainMenu->addAction(QIcon(":/subIcon1.png"),"subEntry1" ); connect( subAction1, &QAction::triggered, this, &MyClasss::subSlot1, Qt::UniqueConnection ); QAction* subAction2 = mainMenu->addAction(QIcon(":/subIcon2.png"), "subEntry2" ); connect( subAction2, &QAction::triggered, this, &MyClasss::subSlot2, Qt::UniqueConnection ); // -------------------------------------------------------------------- QAction* action3 = mainMenu->addAction(QIcon(":/icon3.png"),"Entry3" ); connect( action3, &QAction::triggered, this, &MyClasss::mySlot3, Qt::UniqueConnection ); QAction* action4 = mainMenu->addAction(QIcon(":/icon4.png"), "Entry4" ); connect( action4, &QAction::triggered, this, &MyClasss::mySlot4, Qt::UniqueConnection ); ```
Submenu in a QMenu.
Adding a submenu to a QMenu is really easy, and you add nested submenus if you want:
Fast linked list without list
If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution. Der...
-
Sometimes is useful resizing a QListWidget to the size of its content. This is one way to do it. Don't forget resizing again when you...
-
Adding a submenu to a QMenu is really easy, and you add nested submenus if you want: ```c QMenu* mainMenu; QAction* action1 = mainMenu...