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. List into column
Forum Updated to NodeBB v4.3 + New Features

List into column

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

    then i adding list to column there is an error:
    QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.

    ListView becomes colapsed into 0px line.

    simlified layout:
    @
    Column {
    anchors.fill: parent
    Button {
    id: topBtn
    }
    ListVeiw {
    height: parent.height - topBtn.height - bottomBtn.height
    }
    Button {
    id : bottomBtn
    }
    }
    @

    In Qt Widgets Listview expands height automaticaly.

    ps. sory for my english ;)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      Your simplified example is not enough to reproduce the issue and would not cause this warning. Most likely you have anchors declared inside button or some other part of your code.

      The modified example below works fine:

      @
      import QtQuick 2.0

      Rectangle {
      width: 360
      height: 360
      Column {
      anchors.fill: parent
      Rectangle {
      id: topBtn
      width: parent.width ; height: 20
      color: "red"
      }
      ListView {
      height: parent.height - topBtn.height - bottomBtn.height
      width: parent.width
      model: 20
      delegate: Text { text: modelData}
      }
      Rectangle {
      id : bottomBtn
      width: parent.width ; height: 20
      color: "blue"
      }
      }
      }

      @

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eerie
        wrote on last edited by
        #3

        @
        height: parent.height - topBtn.height - bottomBtn.height
        @
        if add two lists, how can i compute height?
        or if i hide buttons? so i want automaticaly computed height, such as in widgets.

        any workaround?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jens
          wrote on last edited by
          #4

          You probably do not want to use a ListView if you want a fixed height column that resizes to content. ListView is for flickable content that is larger than your screen.

          Instead you can use a Repeater like this.

          @
          Column {
          Repeater {
          model: 20 (or any other list model)
          SomeDelegateItem {}
          }
          }
          @

          1 Reply Last reply
          0
          • E Offline
            E Offline
            eerie
            wrote on last edited by
            #5

            In this way i lose flickable, scroll conditions.
            if put repeater in Flickable - it will be colapsed as listview.)

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jens
              wrote on last edited by
              #6

              Of course. You cant have both. Either you set a fixed size on a ListView by setting the height property or you have a fixed with container that adapts to the height. You have to choose. QListView worked the same way. You can try to hack it by setting the Listview height to it's contentHeight but then what is the point of having it flickable?

              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