Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
右键单击 QGraphicsView 时如何在 Qt 中显示弹出菜单?请帮忙
QGraphicsView派生自QWidget,因此只需重新实现contextMenuEvent(QContextMenuEvent* event)以生成QMenu. 如果您希望在右键单击时出现QGraphicsItems 一个,那么您将不得不contextMenuEvent(QGraphicsSceneContextMenuEvent* event)在项目中重新实现。
QGraphicsView
QWidget
contextMenuEvent(QContextMenuEvent* event)
QMenu
QGraphicsItems
contextMenuEvent(QGraphicsSceneContextMenuEvent* event)