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 property of unknown type "QString".
Forum Updated to NodeBB v4.3 + New Features

Cannot assign to property of unknown type "QString".

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 1.1k 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.
  • H Offline
    H Offline
    Hungkv
    wrote on last edited by
    #1

    I dont know why I got error "Cannot assign to property of unknown type "QString"." when I using string property string and assign it to text property in Text, here is the qml file

    
    import QtQuick
    Item {
        id: root
        required property string title
        required property string data
    
        width: 200*D.w
        height: 30*D.h
    
        Rectangle {
            width: parent.width
            height: parent.height
            color: "transparent"
    
            Text {
                id: titleText
                text: title? title : "Undefined"
                wrapMode: Text.WordWrap
                width: parent.width/3
                height: parent.height
                anchors {
                    left: parent.left
                    top: parent.top
                    bottom: parent.bottom
                }
                horizontalAlignment: Text.AlignHCenter
            }
    
            Text {
                id: dataText
                text: data ? data : "Undefined"
                wrapMode: Text.WordWrap
                width: parent.width*2/3
                height: parent.height
                anchors {
                    left: titleText.right
                    top: parent.top
                    bottom: parent.bottom
                }
                horizontalAlignment: Text.AlignLeft
            }
        }
    }
    
    
    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      Which Qt version are you using?
      Which line in the QML code does the error message refer to?
      I don't think it matters, but you should change the assignment line to

      text: root.title ? root.title : "Undefined"
      

      Software Engineer
      The Qt Company, Oslo

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

        In addition what @Axel-Spoerl has already said, avoid using title, data as your properties. data is already as property in item. So confusing. Better use some other names.

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

        1 Reply Last reply
        1

        • Login

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