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. Cannot assign to non-existent property
Forum Updated to NodeBB v4.3 + New Features

Cannot assign to non-existent property

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 1.7k 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.
  • C Offline
    C Offline
    cosmoff
    wrote on last edited by
    #1

    Hello everybody,

    I create a qml file Bar with the code:

    Bar.qml :

    Item{
    property alias titleText : machineModelText.text
    property alias setPixelSize : machineModelText.font.pixelSize
    
    Text {
            id: machineModelText
            //font.pixelSize: 20
    
            font.capitalization: Font.AllUppercase
            color: topMenuBarGI.modelTextColor
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignLeft
    
            anchors {
                left: parent.left
                top : parent.top
                bottom : parent.bottom
                margins: topMenuBarGI.modelHorizontalMargin
            }
        }
    
    
    }
    

    and in my main.qml I do :

    Bar{
    setPixelSize : 10
    titleText : "Hello"
    }
    

    It works for titleText but not for setPixelSize, I have the error message : Cannot assign to non-existent property "setPixelSize", why ?

    thanks for your help

    YashpalY 1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @cosmoff hi,
      try to alias only the text

      property alias titleText : machineModelText
      

      then

      Bar{
      titleText.font.pixelSize: 10
      titleText.text : "Hello"
      }
      

      edit : but what you did works also for me..

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

        Alias cannot be reference to grouped property.

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

        1 Reply Last reply
        1
        • C Offline
          C Offline
          cosmoff
          wrote on last edited by cosmoff
          #4

          I did :

          titleText.font.pixelSize: 10
          titleText.text : "Hello"
          

          but I have the error message : Invalid grouped property access
          So what can I do ?

          1 Reply Last reply
          0
          • C cosmoff

            Hello everybody,

            I create a qml file Bar with the code:

            Bar.qml :

            Item{
            property alias titleText : machineModelText.text
            property alias setPixelSize : machineModelText.font.pixelSize
            
            Text {
                    id: machineModelText
                    //font.pixelSize: 20
            
                    font.capitalization: Font.AllUppercase
                    color: topMenuBarGI.modelTextColor
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignLeft
            
                    anchors {
                        left: parent.left
                        top : parent.top
                        bottom : parent.bottom
                        margins: topMenuBarGI.modelHorizontalMargin
                    }
                }
            
            
            }
            

            and in my main.qml I do :

            Bar{
            setPixelSize : 10
            titleText : "Hello"
            }
            

            It works for titleText but not for setPixelSize, I have the error message : Cannot assign to non-existent property "setPixelSize", why ?

            thanks for your help

            YashpalY Offline
            YashpalY Offline
            Yashpal
            wrote on last edited by
            #5

            @cosmoff I see nothing wrong in the code. Please verify whether are you referring to the right Bar.qml and also, whether it has property setPixelSize defined.

            1 Reply Last reply
            1
            • C Offline
              C Offline
              cosmoff
              wrote on last edited by
              #6

              it works, the code was good but I had a problem with a library.

              thanks a lot for your help

              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