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



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





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



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



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



  • 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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.