I have an Item Delegate for a TreeView that has several widgets inside a frame for editors at each node. One of the widgets is a QTextEdit that needs to display the 'standard' context menu and also a custom item that unhides a docking window. The docking window is defined at the main window level using the ui designer. I've set the contextmenu policy for the QTextEdit widget to Qt::NoContextMenu, and I get the event in the main window in the ContextMenuEvent. Now, I want to interrogate the event to see if it's from my QTextEdit, and if it is, display the standard context menu with my extra item and if not, display another context menu. I'm stuck on finding out which widget received the right-click. I have tried using :
QTextEdit *txt = qobject_cast<QTextEdit*>( this->childAt( event->globalPos() ) ); and also
QTextEdit *txt = qobject_cast<QTextEdit*>( this->view->childAt( mapFromGlobal( event->globalPos() ) ) ); and several other combinations. But the cast is returning a 0 pointer every time. I need to find out how to use the globalPos() to get the calling widget... but I don't know how to figure it out. Can anyone help? Or suggest a smarter way to approach the issue? Thanks in advance for any assistance.
Bookmarks