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 i can check what parent is existing?
Forum Updated to NodeBB v4.3 + New Features

How i can check what parent is existing?

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

    I try:
    @Rectangle {
    id:wo
    width: parent.width*0.6
    }@

    And I'm getting the error:
    TypeError: Cannot read property of null

    And therefore I want something like:
    @if(parent.exist) return parent.width;
    else return Screen.width;@

    How can I do this?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @
      Rectangle {
      id:wo
      width: (parent === null)? Screen.width : parent.width
      }
      @

      (Z(:^

      1 Reply Last reply
      0
      • N Offline
        N Offline
        ningen
        wrote on last edited by
        #3

        I try it and it's not working.
        If we use:
        @(parent === null)? parent.height : Screen.height@
        result is always true
        If we use:
        @width: (parent === null)? Screen.width : parent.width@
        result is always false

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          What about
          @
          parent === undefined?
          @
          or
          @
          parent.width === undefined
          @

          (Z(:^

          1 Reply Last reply
          0
          • N Offline
            N Offline
            ningen
            wrote on last edited by
            #5

            the same behaviour ((

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              OK. Uncle Google told me this: "link":http://stackoverflow.com/questions/11040472/check-if-object-property-exists-using-a-variable.

              (Z(:^

              1 Reply Last reply
              0
              • N Offline
                N Offline
                ningen
                wrote on last edited by
                #7

                yes, it is. parent is object type which is have the "width"' property, but the parent himself is wasn't created

                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