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 open a Menu little windows on right click inside a treeview...
Qt 6.11 is out! See what's new in the release blog

How to open a Menu little windows on right click inside a treeview...

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 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.
  • jerome_isAviableJ Offline
    jerome_isAviableJ Offline
    jerome_isAviable
    wrote on last edited by
    #1

    now i'm able to catch mouse event right or middle click and see item, parents, childs and all...

    But i'm steel not able to open a little menu.

    I would like after this right click on item/row of TreeView, to open a little menu for select "delete row" to call function: my_treeView::delete_row() {...}

    any link to show an exemple or a way to do it easy ?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      hope it will help you
      http://qt-project.org/forums/viewthread/31805
      http://qt-project.org/doc/qt-4.8/mainwindows-menus.html

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
        wrote on last edited by
        #3

        You can check on Context menu topic on Assistant or look for contextMenuEvent itself. Every widget has addAction. Using this you can do rightClick menus. Search the topics in this forum. You may hit some examples for sure.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        https://www.pthinks.com

        1 Reply Last reply
        0
        • jerome_isAviableJ Offline
          jerome_isAviableJ Offline
          jerome_isAviable
          wrote on last edited by
          #4

          yes this help me a lot and i follow it: works fine.
          i think now that more than the doc, some exemple like this one is really PERFECT and CLEAR. Maybe this could be a good way to add exemple of use in the doc.

          Thanks a lot.

          1 Reply Last reply
          0
          • jerome_isAviableJ Offline
            jerome_isAviableJ Offline
            jerome_isAviable
            wrote on last edited by
            #5

            but also... an other one last question around this...
            i understand that hacker have to make a choice between QmouseEvent for handle the right click OR contextMenu event for handle the right click for the contecxtual menu (and not call the menu from the right click handle... but maybe this can be possible too...).
            So... here is the question:

            If i need two different menus: one for right click and one for middle click, what is the correct way to do it ?

            maybe stay handle the QMouseEvent and call a menu created inside the condition of the right and middle button ? (at reeaseEvent for not loose the treeview event of roll down the tree... right ?) also... need a way for put the menu at correct position...

            but i don't know what could be, for this two menus depend on right OR middle click event which way could be the easy and correct way.

            Could you teach me this please ?

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              well, then you can try to use eventFilter tracking what and where has happened (which button has been pressed or where mouse pointer moved to)
              see http://qt-project.org/doc/qt-4.8/qobject.html#installEventFilter

              1 Reply Last reply
              0
              • jerome_isAviableJ Offline
                jerome_isAviableJ Offline
                jerome_isAviable
                wrote on last edited by
                #7

                ok, i find my way by handle QMouseEvent first and open a menu as shown on your exemples.

                Works fine like that and code seems clear also (happy with that).

                Thanks for your great help.

                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