QMenu menu; menu.addAction("Option 1"); menu.addAction("Option 2"); menu.exec(QCursor::pos());
QMenu menu; QMenu* submenu = menu.addMenu("Submenu"); submenu->addAction("Submenu Option 1"); submenu->addAction("Submenu Option 2"); menu.addAction("Option 3"); menu.exec(QCursor::pos());This example demonstrates how to add submenus to a QMenu. The addMenu() method is used to create a new submenu, which can then have its own actions added to it. Package Library: Qt