Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
tecky last edited by
i have a widget
how can i add a menu (open "item1/item2" if RightClicked it) a simple way
plz dont link to Qt documentation. just show me a simple exemple.
Mario84 last edited by
you have to call setContextMenuPolicy(Qt::CustomContextMenu) on your widget and connect an own slot to the widgets customContextMenuRequested-signal. In this slot create an instance of QMenu with your desired Items as instances of QAction and call exec() on the menu...
And you probably can't avoid reading some documentation (which contains several examples with menus, like "this":http://qt-project.org/doc/qt-4.8/mainwindows-menus.html one)