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. Emitting a QObject signal FROM QML
Qt 6.11 is out! See what's new in the release blog

Emitting a QObject signal FROM QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 505 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.
  • R Offline
    R Offline
    RogueWarrior
    wrote on last edited by
    #1

    Is it possible for QML to have a QObject emit a signal without needing a glue slot in the QObject that with then call emit MySignal?

    For example, you click a QML button and you want that action to emit a signal that could be seen by QObjects. It seems like the only way to do this is have a slot somewhere which would then emit a QObject signal.

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      Signals from Item, QtObject, etc are QObject signals. There's no need to to have an intermediary.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        just call the signal from QML, they are normal functions and are invokable from QML.

        onClicked: yourCppObject.signal()

        R 1 Reply Last reply
        1
        • GrecKoG GrecKo

          just call the signal from QML, they are normal functions and are invokable from QML.

          onClicked: yourCppObject.signal()

          R Offline
          R Offline
          RogueWarrior
          wrote on last edited by
          #4

          @GrecKo Thanks, but I think I'm running into a much deeper implementation question. I'm actually trying to emit a signal across a QRemoteObjects from the replica back to the source. I tried adding a test signal to my .rep file and calling it from the QML app which has the replica but nothing happens on the source side. I don't get any error messages or warnings on either end.

          The only thing that does work is having a slot in the remote object that emits a signal. I can call that slot from QML and that gets handled on the source side. It's an ugly hack but it works.

          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