@james-b-s
Here is a complete example for you to copy, paste and try:
#include <QApplication>
#include <QComboBox>
#include <QDebug>
#include <QHBoxLayout>
#include <QLineEdit>
#if Qt5
#include <QOverload>
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.setGeometry(100, 100, 200, 200);
QHBoxLayout *layout = new QHBoxLayout(&w);
QComboBox *cb = new QComboBox;
cb->setEditable(true);
layout->addWidget(cb);
cb->addItems({"Item1", "Item2", "Item3"});
QObject::connect(cb, &QComboBox::currentIndexChanged,
&w, [cb](int index) { qDebug() << "currentIndexChanged" << index << cb->itemText(index); });
QObject::connect(cb, &QComboBox::textActivated,
&w, [](const QString &text) { qDebug() << "textActivated" << text; });
QObject::connect(cb->lineEdit(), &QLineEdit::returnPressed,
&w, []() { qDebug() << "returnPressed"; });
QObject::connect(cb, QOverload<int>::of(&QComboBox::activated),
&w, [cb](int index) { qDebug() << "activated(int)" << index << cb->itemText(index); });
#if Qt5
QObject::connect(cb, QOverload<const QString &>::of(&QComboBox::activated),
&w, [](const QString &text) { qDebug() << "activated(const QString &)" << text; });
#endif
w.show();
return a.exec();
}
You should be seeing the activated signal, as well as the others. The fact that I have connected slots as lambdas is just to keep the code down: will be the same if they are slot methods.
Note the following. I do not have Qt 5. I am using Qt6. I have put in some stuff for you which I believe will work/be required in your Qt5:
I do not need need to #include <QOverload>. You may need to?
At Qt6 the overload QComboBox::activated(const QString &) has been removed. That means I do not need to have QOverload<int>::of(&QComboBox::activated) at all, I could just have &QComboBox::activated. But I have put it in anyway, as you will need it. At Qt5.15 that overload is deprecated, but still exists.
I cannot compile QOverload<const QString &>::of(&QComboBox::activated) as it no longer exists. I have put it in (I believe correctly) if you want to test it. However, since it will get removed if you upgrade I suggest you stick to the activated(int) version.
Try this. Play with it if you want to move it into your code and use slot methods. If the test works and your later code does not then you have something wrong in your code.