How to connect QActiondirectly to a lambda slot?
QMenu m;
AT:
QAction newSubfolder(QIcon(":/icons/newfolder.png"),tr("New Subfolder"),&m);
m.addAction(&newSubfolder);
connect(&newSubfolder,&QAction::triggered,
this,[this,p](){qDebug()<<"New Subfolder";});
Does not work:
m.addAction(QIcon(":/icons/newfolder.png"),tr("New Subfolder"),
[this,p](){qDebug()<<"New Subfolder";});
Error:
No matching function for call to 'QMenu::addAction(QIcon, QString, FolderMenuWidget::showContextMenu(QPoint)::__lambda0)'
[this,p](){qDebug()<<"New Subfolder";});
^
Yes I see an error message, but I don’t understand what I need to change for the lambda slot. It also does not work if I add a pointer to an element thisbefore the lambda.
This is in Qt 5.3.
source
share