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. How a QML file considers a parent?
Forum Update on Monday, May 27th 2025

How a QML file considers a parent?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 673 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.
  • N Offline
    N Offline
    Nitheesh
    wrote on last edited by A Former User
    #1

    I have a qml file where there is a property declared as below:
    property KeyboardManager keyManager: parent ? parent.manager : null

    where KeyboardManager is a cpp class inherited in qml. unable to find what exactly this line means. Request to clarify.

    Thanks in advance.

    E 1 Reply Last reply
    0
    • N Nitheesh

      I have a qml file where there is a property declared as below:
      property KeyboardManager keyManager: parent ? parent.manager : null

      where KeyboardManager is a cpp class inherited in qml. unable to find what exactly this line means. Request to clarify.

      Thanks in advance.

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Nitheesh Parent is the visual parent of an Item-based object (http://doc.qt.io/qt-5/qtquick-visualcanvas-visualparent.html). When you write your own component which can be re-used in many contexts you don't know what the parent is or if there even is one at all. So this line checks if the created object has a 'parent' and sets your object's keyboard manager property object accordingly - it's either the parent's manager, or null if there's no parent. This will lead to an error if the object has a parent but this parent doesn't have the 'manager' property.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved