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. [SOLVED]Signal from dynamic component to the page where it is created
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Signal from dynamic component to the page where it is created

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.6k 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.
  • P Offline
    P Offline
    pizarro84
    wrote on last edited by
    #1

    Hi,

     QML newbie here. I made a timer that generates dynamic components in QML. I need help in changing values from the page (where the component was created) whenever I interact with those components (ex: clicking the dynamic component changes a variable value/component property in the page where it was created), something like signals and slots. How do I do this? Thanks in advance!
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      msx_br
      wrote on last edited by
      #2

      Im not sure if this will help you, but :

      @
      import QtQuick 1.0

      Rectangle {
      id: rect
      width: 360
      height: 360
      property string my_text: "hello world"

      Text {
          id: textBox
          anchors.centerIn: parent
          text: rect.my_text
      }
      MouseArea {
          id: mouseArea
          anchors.fill: parent
          onClicked: { textBox.color = "blue"; rect.my_text = "goodbye world" }
      }
      states: State {
         name: "change color"; when: mouseArea.pressed
         PropertyChanges { target: rect; color: "blue"; }
      }
      

      }
      @

      msx_br - Brazil (Netherlands)

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pizarro84
        wrote on last edited by
        #3

        Thanks for the reply, actually my problem is that my dynamic component is on another QML file..

        @Page {
        id: splashscreen
        rotation: 0

        Rectangle {
            id:rect
            color: "#d3ff20"
            anchors.fill: parent
            Rectangle {
                id: house
                width: 80; height: 80
                color: "#00000000"
                x: 280
                y: 245
                Image {
                    id: name
                    source: "images/evernote.png"
                    anchors.fill: parent
                }
            }
        
            ProgressBar {
                width: 200
                height: 50
                x: 220; y:310
                maximumValue: 100
                minimumValue: 0
                value: 100
                MouseArea {
                    anchors.fill: parent
        
                }
            }
        
            Timer {
                interval: 800
                running: true
                repeat:  true
        
        
                onTriggered: {
                    if (Qty.currentAliensCount < 10)
                    {
                        createItem(Math.floor(Math.random()*10000)T0,
                                   Math.floor(Math.random()*10000)$0)
                        Qty.currentAliensCount += 1;
                    }
                }
        
            }
        
        
        }
        
        
        function createItem(mx,my)
        {
            //the dynamic component from a separate qml..
            var component = Qt.createComponent("TestItem1.qml"); 
            var sprite = component.createObject(splashscreen,{"x": mx,"y":my});
        }
        

        }@

        And I need to access the properties of components on this page whenever I click the TestItem1 dynamic component

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pizarro84
          wrote on last edited by
          #4

          up! :)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pizarro84
            wrote on last edited by
            #5

            I removed the javascript and created properties instead :)

            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