There is a GraphiscView widget in my dialog, and menu setup is looking:
m_ui->graphicsView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui->graphicsView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showContextMenu(const QPoint&)));
m_ui->graphicsView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui->graphicsView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showContextMenu(const QPoint&)));
To copy to clipboard, switch view to plain text mode
If I add an object of a class, derived from QGraphicsItem, and having this method overriden:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
To copy to clipboard, switch view to plain text mode
, the graphicsView context menu is beig shown, if I right-click on it, not one of the item.
Item's menu is shown only if I comment out set up of graphicsView menu.
How to do it right way, that if I click on an item, its menu is shown, if on an empty field of graphicsView - the graphicsView's menu?
Bookmarks