Given the following two:
connect(ui->comboBox, SIGNAL(activated(QString)), ps, SLOT(requestPlotsAvailable(QString)));
connect(ui->comboBox, &QComboBox::activated, ps, &PlotSystem::requestPlotsAvailable);
The first uses the old notation, which works. The second uses the new notation and gives the error
error: no matching function for call to 'PlotSystemGui::connect(QComboBox*&, <unresolved overloaded function type>)'
How to avoid the error using the new notation?
This should work
connect(ui->comboBox,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
ps,
&PlotSystem::requestPlotsAvailable);
Qt 5.7 introduces qOverload
(or QOverload for C++11) for convenience/readability:
connect(ui->comboBox,
qOverload<const QString &>(&QComboBox::activated),
ps,
&PlotSystem::requestPlotsAvailable);
See this question about pointers to overloaded functions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With