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 onCompleted confusion?
Forum Updated to NodeBB v4.3 + New Features

Component onCompleted confusion?

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

    You can do this:

    Component.onCompleted: {blah blah}
    

    But you cannot do this:

    Component {
        id: blah
        onCompleted: {
            blah blah
        }
        Item {
        }
    }
    

    The second version will come back with:

    "qrc:/CellList.qml:73 Component elements may not contain properties other than id\n"
    

    Instead I need to put a Component.onCompleted inside the Item inside the Component.

    C++ is a perfectly valid school of magic.

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

      onCompleted and onDestruction are attached signals, not owned by Component. Also Component is not an QML element and do not acts like other one.

      1 Reply Last reply
      2
      • fcarneyF fcarney

        You can do this:

        Component.onCompleted: {blah blah}
        

        But you cannot do this:

        Component {
            id: blah
            onCompleted: {
                blah blah
            }
            Item {
            }
        }
        

        The second version will come back with:

        "qrc:/CellList.qml:73 Component elements may not contain properties other than id\n"
        

        Instead I need to put a Component.onCompleted inside the Item inside the Component.

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @fcarney hi
        there might be little confusion because when you create a reusable QML file it is called a qml component, and there is also a QML type called Component

        this can clyrify everything
        https://doc.qt.io/qt-5/qml-qtqml-component.html#details

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

          onCompleted is for the object Creation signal. As suggested by @LeLev you are creating the re-usable component. Move your onCompleted inside the Item object.

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

          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