1.
ui.listWidget_Filelist->setContextMenuPolicy(Qt::CustomContextMenu);
2
void SonicAttribute::on_listWidget_Filelist_customContextMenuRequested(const QPoint &pos)
{
QListWidgetItem* curItem = ui.listWidget_Filelist->itemAt(pos);
if (curItem == NULL)
return;
QMenu *popMenu = new QMenu(this);
QAction *deleteSeed = new QAction(tr("Delete"), this);
popMenu->addAction(deleteSeed);
connect(deleteSeed, SIGNAL(triggered()), this, SLOT(deleteSeedSlot()));
popMenu->exec(QCursor::pos());
delete popMenu;
delete deleteSeed;
}