Re: Multiple Context Menus
you need to do next things:
1. set context menu policy for widget for which context menu will be displayed
Code:
...
m_myWidget->setContextMenuPolicy(Qt::CustomContextMenu);
...
2. connect signal customContextMenuRequested with slot in which context menu will be created
Code:
...
connect(m_myWidget,
SIGNAL(customContextMenuRequested
(const QPoint &)),
SLOT(updateContextMenu
(const QPoint &)));
...
3. create needed context menu and show it
Code:
void AnotherMyWidget
::updateContextMenu(const QPoint &pos
) {
QMenu menu
(tr
("Context Menu"),
this);
//add actions to menu and create connections
menu.exec(m_myWidget->mapToGlobal(pos));
}
Re: Multiple Context Menus
Quote:
Originally Posted by
spirit
you need to do next things:
1. set context menu policy for widget for which context menu will be displayed
2. connect signal customContextMenuRequested with slot in which context menu will be created
3. create needed context menu and show it
This makes the context menu switching easier but doesn't solve the basic problem of making a context menu show up when releasing the right mouse button at the end of a drag.
This is the order of operations I'm looking for:
- right-click and drag from TableA to TableB
- release the right mouse button (now in the dropEvent() code)
- a context menu is displayed
- user makes a selection from the context menu
- drop is processed based upon that selection
Re: Multiple Context Menus
ok, just call
Code:
void AnotherMyWidget
::updateContextMenu(const QPoint &pos
)
after mouse releadse. (you have current point just pass it in method)