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 property/variable declaration with children range of validy
Forum Updated to NodeBB v4.3 + New Features

Component property/variable declaration with children range of validy

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

    Hey,

    i am declarating variables using property. When i declare them in my top-level component the range is global, but when i am declaring them in a children of my top-level component, the range doesnt affect the children, is it possible to create some sort of variable which the children can access like a global variable?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      See http://qt-project.org/doc/qt-5.0/qtqml/qtqml-documents-scope.html#component-scope and http://qt-project.org/doc/qt-5.0/qtquick/qtquick-performance.html#bindings for information about evaluation scope.

      If you want children to be able to access a property, you can declare that property in the root object in the component scope, or as a context property.

      Alternatively, use a Singleton (clearer since you have to prefix usages with the typename, and more optimizable in general).

      Cheers,
      Chris.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        onek24
        wrote on last edited by
        #3

        Hello,

        thanks for your reply. I'll give it a look.

        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