我有一个带有名称的 QTreeView。我在这里添加了一个 contextMenu:
_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)));
当我点击“编辑选择”时,SLOT onEdit() 被正确触发。但是在这里我需要来自我右键单击的 QTreeView 的 QStadardItem (* Pointer 或至少它的 text()) ?我怎样才能访问它?