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. General and Desktop
  4. Send Signals between different Qml Objects
Qt 6.12 LTS is out! See what's new in the release blog

Send Signals between different Qml Objects

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 3.0k Views
  • 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
    nnicou
    wrote on last edited by nnicou
    #1

    Hello,
    I have some items define in different QML files and i load them dynamically base on user option in my main qml. I want when one of these items is clicked to load a specific item in my main QML file.
    As i was searching for a solution for this i tried Signals but i can only make it work if items are defined in main QML. I think the problem lies in the way i initialize my QML items(i dont know if there is otherway around)

    The code below is how i choose which Grid to load (the items are initialized there) base on user option

     function getModelFile()
        {
            if (choice === "1") return "Fourby4Mesh4VCs.qml";
            else if (choice === "2") return "Threeby3Mesh4Vcs.qml";
    
    
        }
    Loader{
                    width:rowLayout.width*0.55
                    height: rowLayout.width*0.55
                    anchors.left: topologyLayout.left
                    anchors.top: topologyLayout.top
                    sourceComponent: none.none
                    id:loadTopology
                    source:getModelFile()
    
                }
    
    E 1 Reply Last reply
    0
    • N nnicou

      Hello,
      I have some items define in different QML files and i load them dynamically base on user option in my main qml. I want when one of these items is clicked to load a specific item in my main QML file.
      As i was searching for a solution for this i tried Signals but i can only make it work if items are defined in main QML. I think the problem lies in the way i initialize my QML items(i dont know if there is otherway around)

      The code below is how i choose which Grid to load (the items are initialized there) base on user option

       function getModelFile()
          {
              if (choice === "1") return "Fourby4Mesh4VCs.qml";
              else if (choice === "2") return "Threeby3Mesh4Vcs.qml";
      
      
          }
      Loader{
                      width:rowLayout.width*0.55
                      height: rowLayout.width*0.55
                      anchors.left: topologyLayout.left
                      anchors.top: topologyLayout.top
                      sourceComponent: none.none
                      id:loadTopology
                      source:getModelFile()
      
                  }
      
      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @nnicou Your code tells nothing, I can't even see how it's related to your question. If you use Loader, did you follow "Receiving signals from loaded objects" in Loader doc?

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
        wrote on last edited by
        #3

        It is about signals between different objects. You are loading QML file through loader. This creates new object that representing that qml file. You can access the object creation loader through id:loadTopology.item.

        You can define connections like this for the signals which are emitted from the qml files which are loaded through loader.

        Connections {
        target : loadTopology.item
        on<Signal>:{

        }
        }

        Please note it is not about signals between qml files. QML files are components. You are creating the objects from these components. Signals/slots communication need to happened between objects.

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

        1 Reply Last reply
        5
        • N Offline
          N Offline
          nnicou
          wrote on last edited by nnicou
          #4

          Sorry i have a edited my post but i am not sure if have explained correct what i am trying to do

          I will add a photo that it may explained better what i ma trying to do
          https://drive.google.com/open?id=0B1zHpsqEO9qBekZUYmZEUndDaWM

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nnicou
            wrote on last edited by nnicou
            #5

            @dheerendra Your post helped me alot and thank you for the explanation.!

            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