我有一个带名字的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(*指针或至少它的text())我在哪里右键单击?我怎样才能访问它?
答案 0 :(得分:0)
解决了myissue: myTreeView.currenIndex();