I'm study C++ Qt. And now try to use lambda function with connect
:
connect(ui->sbNormal, &QSpinBox::valueChanged, [=] (int x) {});
It output error:
error: no matching function for call to 'MainWindow::connect(QSpinBox*&, < unresolved overloaded function type>, MainWindow::MainWindow(QWidget*)::< lambda(int)>)'});
What am I do wrong? How to specify needed overloading?
In case there are multiple overloads, you have to specify which one you want manually:
connect(ui->sbNormal, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
[=] (int x) {});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.