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. Define-time property
Forum Updated to NodeBB v4.3 + New Features

Define-time property

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

    Hi guys,

    I want to create following type of QtQuick item:
    @MyItem {
    id: myItem
    name: "test"
    value: 100
    }@

    name and value should only be write-able at define-time. So when the Object is created on loading the QML file and initializator of the Object is called I can use name and value with the corresponding values. The properties should never be changed at runtime.

    Is there a way to this in QML? The only thing which came to my mind is to use the Component.onCompleted() function and to call a pseudo-initializator but that's not a very clean way I suppose. A behavior like the id has would be great.

    Feel free to check out my website machinekoder.com
    and my pet projects Intellicute and QtQuickVcp

    1 Reply Last reply
    0
    • strahlexS Offline
      strahlexS Offline
      strahlex
      wrote on last edited by
      #2

      Okay I have found: http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-definetypes.html#receiving-notifications-for-object-initialization

      This might probably work.

      Feel free to check out my website machinekoder.com
      and my pet projects Intellicute and QtQuickVcp

      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