Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt QML Signal slot

Qt QML Signal slot

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    narayanan.krish
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vincent007
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved