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. Is it possible to binding "properties" ranther than "property" in Binding?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to binding "properties" ranther than "property" in Binding?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 283 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.
  • K Offline
    K Offline
    Kamichanw
    wrote on last edited by
    #1

    I'm writing Binding for Loader's item. Let's start from my case after simplifying. Assuming that CustomItem is an customized item that has properties named prop1,prop2, and I use it as Loader's source component. When I want to initialize prop1 and prop2 in Loader, I have to do like

    Loader {
        id: loader
        sourceComponent: comp
        Binding {
            target: loader.item
            property: "prop1"
            when: loader.status === Loader.Ready
            value: control.prop1
        }
        Binding {
            target: loader.item
            property: "prop2"
            when: loader.status === Loader.Ready
            value: control.prop2
        }
    }
    

    Is it possible to bind more value in one Binding? Note that you cannot

    Binding {
        loader.item.prop1: control.prop1
        loader.item.prop2: control.prop2
    }
    
    GrecKoG 1 Reply Last reply
    0
    • K Kamichanw

      I'm writing Binding for Loader's item. Let's start from my case after simplifying. Assuming that CustomItem is an customized item that has properties named prop1,prop2, and I use it as Loader's source component. When I want to initialize prop1 and prop2 in Loader, I have to do like

      Loader {
          id: loader
          sourceComponent: comp
          Binding {
              target: loader.item
              property: "prop1"
              when: loader.status === Loader.Ready
              value: control.prop1
          }
          Binding {
              target: loader.item
              property: "prop2"
              when: loader.status === Loader.Ready
              value: control.prop2
          }
      }
      

      Is it possible to bind more value in one Binding? Note that you cannot

      Binding {
          loader.item.prop1: control.prop1
          loader.item.prop2: control.prop2
      }
      
      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      @Kamichanw
      You could write a type that does that (inspect its own meta object, and bind properties declared in it to its target).

      Or you couse use an instantiator:

      Instantiator {
          model: ["prop1", "prop2"]
          delegate: Binding {
              targer: loader.item
              property: modelData
              value: control[modelData]
         } 
      } 
      
      K 1 Reply Last reply
      1
      • GrecKoG GrecKo

        @Kamichanw
        You could write a type that does that (inspect its own meta object, and bind properties declared in it to its target).

        Or you couse use an instantiator:

        Instantiator {
            model: ["prop1", "prop2"]
            delegate: Binding {
                targer: loader.item
                property: modelData
                value: control[modelData]
           } 
        } 
        
        K Offline
        K Offline
        Kamichanw
        wrote on last edited by
        #3

        @GrecKo This is really amazing... Just like magic...

        1 Reply Last reply
        0
        • K Kamichanw has marked this topic as solved on

        • Login

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