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. Hide qml item?
QtWS25 Last Chance

Hide qml item?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
visibility
3 Posts 2 Posters 16.9k 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.
  • M Offline
    M Offline
    manuelschneid3r
    wrote on 7 Feb 2016, 18:51 last edited by
    #1

    How can I hide an item in qm. I mean really hiding it, so e.g. a Column wont display empty space for its height.

    J 1 Reply Last reply 7 Feb 2016, 20:56
    1
    • M manuelschneid3r
      7 Feb 2016, 18:51

      How can I hide an item in qm. I mean really hiding it, so e.g. a Column wont display empty space for its height.

      J Offline
      J Offline
      johnsmith
      wrote on 7 Feb 2016, 20:56 last edited by johnsmith 2 Jul 2016, 20:58
      #2

      @manuelschneid3r

      Set the visible property of the item to false. For example, this code produces a column that consists of two columns of three rectangles, but only one takes space because the other one is not visible:

      import QtQuick 2.3
      import QtQuick.Controls 1.2
      import QtQuick.Window 2.2
      
      ApplicationWindow {
          title: qsTr("Hello World")
          Column {
              Column {
                  spacing: 2
                  visible: false
                  Rectangle { color: "red"; width: 50; height: 50 }
                  Rectangle { color: "green"; width: 20; height: 50 }
                  Rectangle { color: "blue"; width: 50; height: 20 }
              }
              Column {
                  spacing: 2
                  visible: true
                  Rectangle { color: "red"; width: 50; height: 50 }
                  Rectangle { color: "green"; width: 20; height: 50 }
                  Rectangle { color: "blue"; width: 50; height: 20 }
              }
          }
      }
      

      Conversely, you could also hide in the same way, for example, one of the rectangles of one of the columns. If you do that and change each column's visible property to true or false you'll see the difference: one column will have two elements, the other will have three.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        manuelschneid3r
        wrote on 9 Feb 2016, 16:18 last edited by
        #3

        This is what I did. Later I discovered that the problem was that the height of the parent relied on the cildren rect, which is somehow buggy. Thank you for clearifying this.

        1 Reply Last reply
        2

        1/3

        7 Feb 2016, 18:51

        • Login

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