Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt QML Signal slot



  • Hello all !

    I am trying to emit a signal from Qt to QML file.
    I tried to implement it as shown below.
    But the slot_test in qml is not being called.
    Kindly help to fix it.

    @
    void ProcessInfo::init()
    {
    emit emit_test();
    }
    @

    @
    int main(int argc, char *argv[])
    {
    QQmlApplicationEngine engine(QUrl("main.qml"));
    QObject *topLevel = engine.rootObjects().value(0);
    QObject::connect(&settings, SIGNAL(emit_test()), topLevel, SLOT(slot_test()));
    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
    if ( !window ) {
    qWarning("Error: Your root item has to be a Window.");
    return -1;
    }
    window->show();
    return app.exec();
    }
    @

    Thanks & Regards,
    Narayanan K


  • Qt Champions 2017

    Did you confirm that signal is emitted ? Complete code snippet would help including the QML file and how and where you are calling emit ensure that signal is really emitted.



  • Where do you call "void ProcessInfo::init()" ?


Log in to reply