1

I have got this piece of code with a lambda function:

QMenu menu(this);
menu.addAction("Set file", this, [this, i](){this->setFile(i);});

where setFile(int i) is a void method defined in the MyMainWindow class.

It works when compiling with MSVC2015, but not with gcc 4:4.9.2-2, which gives this error:

error: no matching function for call to 'QMenu::addAction(const char [6], MyMainWindow*, MyMainWindow::eventFilter(QObject*, QEvent*)::)' menu.addAction("Set file", this, this, i{this->setFile(i);});

My qmake file contains:

CONFIG += c++11

and I have also tried adding:

QMAKE_CXXFLAGS += -std=c++11

But that did not solve the issue. How can I compile this code?

mimo
  • 2,469
  • 2
  • 28
  • 49

0 Answers0