#include #include struct ObjectNameSlot { QString name; void operator() (const QString &objectName) { name = objectName; } }; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); ObjectNameSlot slot; QObject::connect(&a, &QCoreApplication::objectNameChanged, std::ref(slot)); a.setObjectName("A"); Q_ASSERT(slot.name == "A"); return a.exit(0); }