实现protected contextMenuEvent函数
void MyItem::contextMenuEvent(QContextMenuEvent event) { QMenu menu; QAction moveAction = menu.addAction(“move back”); QAction actAction = menu.addAction(“test”); QAction selectedAction = menu.exec(QCursor::pos()); if(selectedAction == moveAction) { setPos(0, 0); } }
免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:Qt中右键菜单的生成方式:contextMenuEvent https://www.yhzz.com.cn/a/13949.html