Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add context menu in a QCombo box
Forum Updated to NodeBB v4.3 + New Features

How to add context menu in a QCombo box

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Divy Prakash
    wrote on last edited by
    #1

    I am using a QCombo box to display a list of items,for each item i want a context menu i.e.,on each item of the list, if we right click it should show "Delete" item.

    What is the best possible way to do it?

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      Set "contextMenuPolicy":http://qt-project.org/doc/qt-4.8/qwidget.html#contextMenuPolicy-prop for combo box to Qt::CustomContextMenu and connect "customContextMenuRequested":http://qt-project.org/doc/qt-4.8/qwidget.html#customContextMenuRequested to your slot. In this slot you can call "QMenu::exec":http://qt-project.org/doc/qt-4.8/qmenu.html#exec-2 with point passed in slot function

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Divy Prakash
        wrote on last edited by
        #3

        I did the same way but then the context menu comes only for the first item in the list and when i click on the drop down list the context menu does not comes for each and every item in the list

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved