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. Connecting QML signals with Qt slots.
Forum Updated to NodeBB v4.3 + New Features

Connecting QML signals with Qt slots.

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 10.0k 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.
  • K Offline
    K Offline
    kibsoft
    wrote on 11 Nov 2010, 22:03 last edited by
    #1

    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
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on 11 Nov 2010, 22:41 last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbrasser
        wrote on 12 Nov 2010, 01:47 last edited by
        #3

        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
        0
        • K Offline
          K Offline
          kibsoft
          wrote on 12 Nov 2010, 08:32 last edited by
          #4

          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
          0
          • M Offline
            M Offline
            mbrasser
            wrote on 14 Nov 2010, 23:56 last edited by
            #5

            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
            0
            • K Offline
              K Offline
              kibsoft
              wrote on 15 Nov 2010, 14:50 last edited by
              #6

              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
              0

              1/6

              11 Nov 2010, 22:03

              • Login

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