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. [SOLVED] Height of ListView delegate(multidelegate)
Forum Update on Monday, May 27th 2025

[SOLVED] Height of ListView delegate(multidelegate)

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 7.6k 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.
  • H Offline
    H Offline
    huot
    wrote on 28 Mar 2012, 19:30 last edited by
    #1

    How can I set the height of multiDelegate? The height of multiDelegate depends on type of delegate (imgDelegate or txtDelegate)

    Below my delegate code (MultiDelegate.qml)

    @
    import QtQuick 1.1

    Item {
    id: multiDelegate
    width: multiDelegate.ListView.view.width

    Component {
    id: imgDelegate

    Image {
      id: img
      source: value
      fillMode: Image.PreserveAspectFit
      asynchronous: true
    }
    

    }

    Component {
    id: txtDelegate

    Text {
      id: txt
      text: value
      verticalAlignment: Text.AlignVCenter
      horizontalAlignment: Text.AlignHCenter
      wrapMode: Text.Wrap
    }
    

    }

    Loader {
    id: itemDisplay
    anchors.fill: parent;
    anchors.topMargin: 2
    anchors.bottomMargin: 2
    sourceComponent: type ? imgDelegate : txtDelegate
    }

    }@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on 30 Mar 2012, 20:01 last edited by
      #2

      Hello,

      Try following:

      1. Set @ multiDelegate.height: itemDisplay.height @

      According to documentation:
      bq. If an explicit size is not specified for the Loader, the Loader is automatically resized to the size of the loaded item once the component is loaded.

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • H Offline
        H Offline
        huot
        wrote on 1 Apr 2012, 15:44 last edited by
        #3

        I tried following

        @
        import QtQuick 1.1

        Item {
        id: multiDelegate
        width: multiDelegate.ListView.view.width
        height: itemDisplay.height
        @

        but it didn't work. I got following error

        @
        MainPage.qml QML Item: Binding loop detected for property "height"
        MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
        MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
        MainPage.qml QML Item: Binding loop detected for property "height"
        MainPage.qml QML Item: Binding loop detected for property "height"
        MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
        @

        1 Reply Last reply
        0
        • H Offline
          H Offline
          huot
          wrote on 1 Apr 2012, 18:41 last edited by
          #4

          Problem solved

          I modified Loader element like this

          @
          Loader {
          id: itemDisplay
          sourceComponent: type ? imgDelegate : txtDelegate
          }
          @

          1 Reply Last reply
          0

          1/4

          28 Mar 2012, 19:30

          • Login

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