Thanks. That will work. Mike J.
On May 10, 2013, at 4:48 PM, Andreas Pakulat wrote: > Hi, > > > On Fri, May 10, 2013 at 10:06 PM, Michael Jackson <imikejack...@gmail.com> > wrote: > I am trying to add a "right click" or context menu to a QTreeWidget where the > menu that gets popped up has menus that are specific to the item being > clicked on. So far all my attempts have failed. > > I have tried to add my higher level QWidget class (The parent of the > QTreeWidget) as an Event Filter for the QTreeWidget but I am not receiving > the mouse clicked events. I tried adding the QAction to the QTreeWidgetItem > directly by getting the QWidget from the QTreeWidgetItem while it is being > constructed but at that point in the code the QTreeWidgetItem does not have a > QWidget yet so that does not work. > > I am hoping it is something simple that I am just missing. Any help would be > greatly appreciated. > > Your three options are: > > a) override contextMenuEvent in the QTreeWidget and map the x/y position to > an item using QTreeWidget::itemAt() (make sure to keep the default context > menu policy on the QTreeWidget > > b) add QAction's to the QTreeWidget and set the contextMenuPolicy to > Qt::ActionsContextMenu, then fetch the list of selected items from the > TreeWidget in the actions triggered-slots using QTreeWidget::selectedItems > > c) set the contextMenuPolicy to Qt::CustomContextMenu and connect yourself to > the 'customContextMenuRequested' signal, then again map from the given point > to the item using QTreeWidget::itemAt() > > Andreas > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest