QT version: 5.14.2
Language: C++
Issue: As the picture, when to click the right button, the context menu will not display immediately sometimes.
Code:
Код: Выделить всё
projectTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
menu = new QMenu;
menu->addAction(createAction);
menu->addAction(deleteAction);
connect(projectTreeView, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos){
QModelIndex index = projectTreeView->indexAt(pos);
if (!index.isValid())
return;
else
{
qDebug() exec(QCursor::pos());
}
});
Подробнее здесь: https://stackoverflow.com/questions/796 ... lick-event
Мобильная версия