Important: Please read the Qt Code of Conduct -


  • 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.

  • 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": one)

Log in to reply