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. [SOLVED] How to define default property of type list in qml
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to define default property of type list in qml

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.6k 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.
  • F Offline
    F Offline
    feldifux
    wrote on last edited by
    #1

    Hi,
    I'm trying to create a custom default property for an Item which should act like the children default property, but only accepting my custom types.

    E.g. this is how I would like the QML item to be used:
    @MyComponent {
    MyItem { }
    MyItem { }
    MyItem { }
    }@

    Therefore I tried to set the following default property definition in MyComponent:
    @default property list <MyItem> myChildren@

    But this results in errors:
    "Unexpected token '<'" and "Expected token ':'"

    How to do that with Qt 5?

    Thanks,
    Chris

    Founder of Felgo SDK - http://felgo.com/qt

    Felgo simplifies

    • Mobile App Dev with Qt esp. iOS & Android
    • Game Development with Qt

    What others say

    Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      see https://bugreports.qt-project.org/browse/QTBUG-10822

      you can try,

      @
      id: root
      property list <MyItem> myChildren
      default property alias children: root.myChildren
      @

      Do you test your code in Qt 5.3?

      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