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. How to set properties of a property alias?
Forum Updated to NodeBB v4.3 + New Features

How to set properties of a property alias?

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

    In Dummy.qml

    import QtQuick
    
    Item {
        property alias dummy: dummy
    
        Item {
            id: dummy
            property int dummyInt: 0
        }
    }
    
    

    And I want to use Dummy in main.qml and set proprety of dummy directly, but an error occurred: Cannot assign to non-existent property "dummyInt"

    Dummy {
        dummy.dummyInt: 1
    }
    
    B GrecKoG 2 Replies Last reply
    0
    • K Kamichanw

      In Dummy.qml

      import QtQuick
      
      Item {
          property alias dummy: dummy
      
          Item {
              id: dummy
              property int dummyInt: 0
          }
      }
      
      

      And I want to use Dummy in main.qml and set proprety of dummy directly, but an error occurred: Cannot assign to non-existent property "dummyInt"

      Dummy {
          dummy.dummyInt: 1
      }
      
      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by GrecKo
      #3

      @Kamichanw said in How to set properties of a property alias?:

      Item {
      property alias dummy: dummy

      Item {
          id: dummy
          property int dummyInt: 0
      }
      

      }

      This is because the alias thinks dummy is just an Item. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.

      To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:

      Item {
          property alias dummy: dummy
      
          component InnerDummy: Item {
              property int dummyInt: 0
          }
      
          InnerDummy {
              id: dummy
          }
      }
      
      K 1 Reply Last reply
      4
      • K Kamichanw

        In Dummy.qml

        import QtQuick
        
        Item {
            property alias dummy: dummy
        
            Item {
                id: dummy
                property int dummyInt: 0
            }
        }
        
        

        And I want to use Dummy in main.qml and set proprety of dummy directly, but an error occurred: Cannot assign to non-existent property "dummyInt"

        Dummy {
            dummy.dummyInt: 1
        }
        
        B Offline
        B Offline
        Bob64
        wrote on last edited by
        #2
        This post is deleted!
        1 Reply Last reply
        1
        • K Kamichanw

          In Dummy.qml

          import QtQuick
          
          Item {
              property alias dummy: dummy
          
              Item {
                  id: dummy
                  property int dummyInt: 0
              }
          }
          
          

          And I want to use Dummy in main.qml and set proprety of dummy directly, but an error occurred: Cannot assign to non-existent property "dummyInt"

          Dummy {
              dummy.dummyInt: 1
          }
          
          GrecKoG Offline
          GrecKoG Offline
          GrecKo
          Qt Champions 2018
          wrote on last edited by GrecKo
          #3

          @Kamichanw said in How to set properties of a property alias?:

          Item {
          property alias dummy: dummy

          Item {
              id: dummy
              property int dummyInt: 0
          }
          

          }

          This is because the alias thinks dummy is just an Item. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.

          To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:

          Item {
              property alias dummy: dummy
          
              component InnerDummy: Item {
                  property int dummyInt: 0
              }
          
              InnerDummy {
                  id: dummy
              }
          }
          
          K 1 Reply Last reply
          4
          • K Kamichanw has marked this topic as solved on
          • GrecKoG GrecKo

            @Kamichanw said in How to set properties of a property alias?:

            Item {
            property alias dummy: dummy

            Item {
                id: dummy
                property int dummyInt: 0
            }
            

            }

            This is because the alias thinks dummy is just an Item. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.

            To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:

            Item {
                property alias dummy: dummy
            
                component InnerDummy: Item {
                    property int dummyInt: 0
                }
            
                InnerDummy {
                    id: dummy
                }
            }
            
            K Offline
            K Offline
            Kamichanw
            wrote on last edited by
            #4

            @GrecKo Awesome!!! This solved my confusion for a long time. I once thought it was impossible.

            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