Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Not able to receive signal in more than one QML file
Qt 6.12 LTS is out! See what's new in the release blog

Not able to receive signal in more than one QML file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 799 Views 2 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.
  • G Offline
    G Offline
    Gery
    wrote on last edited by Gery
    #1

    Hi all,
    I am new to Qt and QML. Signal emitted from cpp file is not received by two of my QML files. Though I am able to receive the signal in one QML but why it is not received by another QML.I have used
    engine.rootContext()->setContextProperty("my module",&myfile) in main.cpp and using connections in both qml file
    Connections{
    target: myfile
    function onSignal1() {
    }
    }
    It works in one file.

    Thanks in advance.

    sierdzioS 2 Replies Last reply
    1
    • G Gery

      Hi all,
      I am new to Qt and QML. Signal emitted from cpp file is not received by two of my QML files. Though I am able to receive the signal in one QML but why it is not received by another QML.I have used
      engine.rootContext()->setContextProperty("my module",&myfile) in main.cpp and using connections in both qml file
      Connections{
      target: myfile
      function onSignal1() {
      }
      }
      It works in one file.

      Thanks in advance.

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Gery how do you connect to your signal in both QML files?

      (Z(:^

      1 Reply Last reply
      1
      • G Gery

        Hi all,
        I am new to Qt and QML. Signal emitted from cpp file is not received by two of my QML files. Though I am able to receive the signal in one QML but why it is not received by another QML.I have used
        engine.rootContext()->setContextProperty("my module",&myfile) in main.cpp and using connections in both qml file
        Connections{
        target: myfile
        function onSignal1() {
        }
        }
        It works in one file.

        Thanks in advance.

        sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        @Gery said in Not able to receive signal in more than one QML file:

        You register my module as object name, but you try to connect to myfile. That might be one part of the problem. Another (just a guess) is that when signal is sent, only one of the QML files is open and loaded by the engine. So the other one does not receive the signal because it's not a live object.

        engine.rootContext()->setContextProperty("my module",&myfile) 
        
        Connections{
          target: myfile
          function onSignal1() {
          }
        }
        

        (Z(:^

        G 1 Reply Last reply
        0
        • sierdzioS sierdzio

          @Gery said in Not able to receive signal in more than one QML file:

          You register my module as object name, but you try to connect to myfile. That might be one part of the problem. Another (just a guess) is that when signal is sent, only one of the QML files is open and loaded by the engine. So the other one does not receive the signal because it's not a live object.

          engine.rootContext()->setContextProperty("my module",&myfile) 
          
          Connections{
            target: myfile
            function onSignal1() {
            }
          }
          
          G Offline
          G Offline
          Gery
          wrote on last edited by
          #4

          @sierdzio sorry for typo, I have used myModule only and its working in one. Is there any work around to work with same live object, is it using singleton object, I am bit stuck on it.

          sierdzioS 1 Reply Last reply
          0
          • G Gery

            @sierdzio sorry for typo, I have used myModule only and its working in one. Is there any work around to work with same live object, is it using singleton object, I am bit stuck on it.

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            @Gery from the point of view of the QML engine, your root context property already is a singleton (it is a single, global object, visible from all QML code).

            If your other QML file is not loaded when signal is emitted, you have 2 options I think:

            • Load the file earlier (maybe with a Loader? It's really hard to say for me since I don't know your code)
            • make sure the data from signal is available in your myModule object later, when the other QML file needs it. For example, myModule can have a Q_PROPERTY which holds the data. Then QML can always access it easily

            (Z(:^

            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
            • Unsolved