0
我有一個帶名稱的QTreeView。我添加了一個文本菜單如下:當在QTreeView上右鍵單擊(contextMenu)時,檢索相應的QStandardItem
_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(*指針或至少它的文本()),我右鍵單擊它?我怎樣才能訪問?