Is it possible to connect a signal to a static slot without a receiver instance?

前端 未结 3 1419
天命终不由人
天命终不由人 2020-12-01 17:44

Is it possible to connect a signal to static slot without receiver instance?

Like this: connect(&object, SIGNAL(some()), STATIC_SLOT(staticFooMember()));

3条回答
  •  时光取名叫无心
    2020-12-01 18:31

    It is. (With Qt5)

    #include 
    #include 
    
    void foo(){
        qDebug() << "focusChanged";
    }
    
    
    int main(int argc, char *argv[]) {
        QApplication app(argc, argv);
        QObject::connect(&app, &QApplication::focusChanged, foo);
        return app.exec();
    }
    

提交回复
热议问题