-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
None
-
None
I really miss an overload for `QObject::connect` with the following signature:
QObject::connect(const QObject *sender, const QMetaMethod &signal, Functor functor)
I would propose a diff but I'm not familiar in this code..
My example is that I am wanting to monitor a named set of properties by connecting to these properties' notify signals:
#include <QCoreApplication>
#include <QMetaProperty>
#include <QDebug>
void observeProperties(QObject *object) {
auto *mo = object->metaObject();
for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) {
auto prop = mo->property(i);
if (QString::fromLatin1(prop.name()).startsWith("observeMe")) {
qWarning() << "found prop" << prop.name();
QObject::connect(object, prop.notifySignal(), []() {
// No such overload
});
}
}
}
class Foo : public QObject {
Q_OBJECT
Q_PROPERTY(bool observeMePlease MEMBER m_please NOTIFY pleaseChanged)
public:
using QObject::QObject;
signals:
void pleaseChanged();
private:
bool m_please{false};
};
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
Foo foo;
observeProperties(&foo);
}
#include "main.moc"
- is replaced by
-
QTBUG-120631 Signal QMetaMethod connection to parameter-less lambda
-
- Closed
-