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. Component objects cannot declare new properties
Forum Updated to NodeBB v4.3 + New Features

Component objects cannot declare new properties

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

    If I don't use Button element in the Component, it doesn't give me the above error.

    e.g. This works fine

    Component {
    
      Row {
            Rectangle {..}
            Rectangle {..}
            Rectangle {..}
            Rectangle {..}
       }
    }
    

    But if I add Button element as below, it gives me the mentioned error in the application output

    Component {
          id: itemDelegate
          Button { .. }
          Row {
                Rectangle {..}
                Rectangle {..}
                Rectangle {..}
                Rectangle {..}
           }
    }
    

    I'm using the Component as a delegate

    KroMignonK 1 Reply Last reply
    0
    • P pingal

      If I don't use Button element in the Component, it doesn't give me the above error.

      e.g. This works fine

      Component {
      
        Row {
              Rectangle {..}
              Rectangle {..}
              Rectangle {..}
              Rectangle {..}
         }
      }
      

      But if I add Button element as below, it gives me the mentioned error in the application output

      Component {
            id: itemDelegate
            Button { .. }
            Row {
                  Rectangle {..}
                  Rectangle {..}
                  Rectangle {..}
                  Rectangle {..}
             }
      }
      

      I'm using the Component as a delegate

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #2

      @pingal said in Component objects cannot declare new properties:

      But if I add Button element as below, it gives me the mentioned error in the application output

      AFAIK, Component can hold only 1 root object (eg. Item, Rectangle, Row ect.). It is same a creating a QML file for a component (cf. https://doc.qt.io/qt-5/qml-qtqml-component.html)
      You should change your code to:

      Component {
          id: itemDelegate
          Item {
              Button { .. }
              Row {
                  Rectangle {..}
                  Rectangle {..}
                  Rectangle {..}
                  Rectangle {..}
              }
        }
      }
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      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