如何给tablewidget整行条目加右键菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何给tablewidget整行条目加右键菜单相关的知识,希望对你有一定的参考价值。
下面是我给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()); 参考技术A 改下就可以了 复制代码 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());以上是关于如何给tablewidget整行条目加右键菜单的主要内容,如果未能解决你的问题,请参考以下文章