在 QTreeView 上右键单击(上下文菜单)时检索相应的 QStandardItem

Retrieve corresponding QStandardItem when rightclicked (contextMenu) on QTreeView

我有一个带有名称的 QTreeView。我在这里添加了一个上下文菜单:

  _treeMenu = new QMenu(myTreeView);
  _editTreeViewAction = new QAction("Edit Selection", _treeMenu);
  _deleteTreeViewAction = new QAction("Delete Selection",_treeMenu);
  myTreeView->addAction(_editTreeViewAction);
  myTreeView->addAction(_deleteTreeViewAction);
  myTreeView->setContextMenuPolicy(Qt::ActionsContextMenu);

  connect(_editTreeViewAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool)));
  connect(_deleteTreeViewAction, SIGNAL(triggered(bool)), this, SLOT(onDelete(bool)));

当我点击 'Edit Selection' 时,SLOT onEdit() 被正确触发。但在这里我需要 QStadardItem(* 指针或至少它的文本())来自我右键单击的 QTreeView ?我怎样才能访问它?

这解决了我的问题: myTreeView.currenIndex();