下面是我给treeWidget加的右键。。。楼主参考下,改下就可以了
复制代码
private slots:
on_treeWidget_customContextMenuRequested(QPoint pos);
复制代码
ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
void Composer::on_treeWidget_customContextMenuRequested(QPoint pos)
{
currentItem = ui->treeWidget->itemAt( pos );
if( currentItem == 0)
return;
QMenu *treeWidgeMenu = new QMenu(ui->treeWidget);
treeWidgeMenu->addAction(ui->actionS_rename);
treeWidgeMenu->addAction(ui->actionCollpase_Rooms);
treeWidgeMenu->addAction(ui->actionUpdate_Driver);
treeWidgeMenu->addSeparator();
treeWidgeMenu->addAction(ui->actionS_delete);
treeWidgeMenu->exec(QCursor::pos());
}