Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Connecting QML signals with Qt slots.

    QML and Qt Quick
    2
    6
    9597
    Loading More Posts
    • 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.
    • K
      kibsoft last edited by

      Hi! I have such code:

      @Item {
      signal itemClicked()

      MouseArea {
      anchor.fill: parent
      onClicked: itemClicked()
      }
      }@

      Can I connect itemClicked() to slot in cpp application?

      @QDeclarativeEngine *engine = new QDeclarativeEngine;
      QDeclarativeComponent component(engine, QUrl::fromLocalFile("qml/TestQML/TestQML.qml"));
      QObject *myObject = component.create();
      QDeclarativeItem item = qobject_cast<QDeclarativeItem>(myObject);
      qDebug()<<QObject::connect(item, SIGNAL(titleBarClicked()), &viewer, SLOT(showMaximized()));@

      connect() retuns true, but it doesn't work.

      1 Reply Last reply Reply Quote 0
      • ?
        Guest last edited by

        see if "this":http://wiki.forum.nokia.com/index.php/CS001625_-_Connecting_Qt_signal_to_QML_function helps

        1 Reply Last reply Reply Quote 0
        • M
          mbrasser last edited by

          In the example the connect has titleBarClicked and the QML has itemClicked, is that just a typo? (if so, I don't see obviously wrong -- it looks like it should be working)

          1 Reply Last reply Reply Quote 0
          • K
            kibsoft last edited by

            bq. In the example the connect has titleBarClicked and the QML has itemClicked, is that just a typo?

            Yes, it's a typo. But it doesn't work :(

            bq. see if this helps

            I need reverse connection..

            1 Reply Last reply Reply Quote 0
            • M
              mbrasser last edited by

              Hi,

              Could you add a bug report on "http://bugreports.qt.nokia.com":bugreports.qt.nokia.com with a small example to reproduce the problem?

              Thanks,
              Michael

              1 Reply Last reply Reply Quote 0
              • K
                kibsoft last edited by

                I've tried this feature in a simple project and it works. So the mistake somewhere in the my test app.

                P.S. You can see this "code example":http://www.fileconvoy.com/filelist.php?id=gfd6e298a19c42fa5359453643e0534cdae6ef.

                Maybe you are know what's wrong :)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post