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.
我想知道我们如何为 qtreewidgetitem 设置上下文菜单,如果我右键单击 qtreewidget 中的每个项目,我应该有一些选项,如编辑、删除 ..我想知道我们如何实现这个。谢谢提前
创建多个动作,例如“编辑”、“删除”、... 调用 myTreeWidget->addAction( actionEdit ) 调用 myTreeWidget->setContextMenuPolicy( Qt::ActionsContextMenu )
将插槽连接到 QAction::triggered 信号,从那里检索项目选择并执行您的代码。