直接上自己的代码:
void Tree::contextMenuEvent(QContextMenuEvent *e)
{
//QItemSelection *selection = new QItemSelection();
//if(ReaderName->text(0)== "AA-AA-AA-00-01")
{
if(!itemAt(mapFromGlobal(QCursor::pos())))
{
Tag_Action = new QMenu(this);
Settings = new QAction(tr("Reader Settings and Diagnostics"),this);
Register = new QAction(tr("Register Map"),this);
Tag_Action->addAction(Settings);
connect(Settings, SIGNAL(triggered()),this, SLOT(goToSettings()));
Tag_Action->addAction(Register);
Tag_Action->exec(QCursor::pos());
}
}现在可以点击item弹出菜单了,但是我想能获取到item第一列的信息改如何做?还有就是我想再不同的item上点击的时候谈出不用的菜单,改如何做?