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. Regarding context menu
Qt 6.11 is out! See what's new in the release blog

Regarding context menu

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 2.4k 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.
  • I Offline
    I Offline
    Indrajeet
    wrote on last edited by
    #1

    Hi All

    I have created a Qwidget window on which i have place QTreeWidget.
    Then i have created a context menu,& on right click of mouse i tried to show this context menu.
    But I am not able to connect my signal to the slot.

    SIGNAL:
    @
    connect(treewidgetptr,SIGNAL(customContextMenuRequested ( const QPoint & pos ) ),this,SLOT(contextMenuEvent(QContextMenuEvent * event )));@

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by JohanSolo
      #2

      The signal and the slot must have the same arguments, here you have QPoint and QContextMenuEvent types.

      From the doc: "The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot."

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        In addition, you should not pass any parameter names, just types.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          octal
          wrote on last edited by
          #4

          If your context menu is based on QAction, you just can set the contextMenuPolicy to Qt::ActionsContextMenu.

          Then, all you need to do is insering your actions with "QWidget::addAction":http://doc.qt.nokia.com/latest/qwidget.html#addAction

          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