i need help.
i want QTreeWidgetItem to show contextMenu on it be click, can somebody tell me how to make it?
thanks
Printable View
i need help.
i want QTreeWidgetItem to show contextMenu on it be click, can somebody tell me how to make it?
thanks
You will need to override treewidget context menu function.
In this check if any item is under it and show menu based on the item.
You can also ContextMenu ready in items, and from treewidget contextmenu function, get this menu and show it.
or may be you can call some treewidget item function from treewidget contextmenu event.
Hope something works for you :)
at the first you need to set context menu policy for QTreeWidget
then connect customContextMenuRequested with the slot which will create a context menuCode:
... m_tree->setContextMenuPolicy(Qt::CustomContextMenu); ...
and last you need to create that slotCode:
... ...
Code:
{ if (!item) return; //add needed actions menu.exec(m_tree->viewport()->mapToGlobal(pos)); }
thanks everyone,i have work out the question follow your
Thanks for such a nice reply . But here i am facing some problem like the action is being performed when we are clicking on any part of the UI .
My requirement is whenever the user click on that menuitem , that time only the action shall be performed .
So, you resurrected a 3.5 year old thread to tell us that something in a program you don't describe does something you don't expect when you click somewhere. Don't be surprised when no magic bullet answer is forthcoming.