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. ListView Size problem
Qt 6.11 is out! See what's new in the release blog

ListView Size problem

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 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.
  • Bhushan_SureB Offline
    Bhushan_SureB Offline
    Bhushan_Sure
    wrote on last edited by
    #1

    @dheerendra @J-Hilk @LeLev @Yunus

    When i click down-arrow of keyboard then focus get changed and it shows next listview element, but problem here is, initially it is showing 2 Listelement but as i go down so after 2 listelement it's height is getting increased and when i go at last element, it's height comes back to original.

    what is the problem here, why the height is changing as i am going from 1 element to last element ???

    import QtQuick 2.6
    import QtQuick.Window 2.2
    
    Rectangle
    {
        id:top
        visible: true
        width: 100
        height: 150
    
        ListModel
        {
            id:time
            ListElement{time_scale:"30 MIN"}
            ListElement{time_scale:"1 HOUR"}
            ListElement{time_scale:"2 HOUR"}
            ListElement{time_scale:"3 HOUR"}
            ListElement{time_scale:"4 HOUR"}
            ListElement{time_scale:"5 HOUR"}
            ListElement{time_scale:"6 HOUR"}
        }
    
        Component
        {
            id:comp
            Rectangle
            {
                width: parent.width
                height: 40
                color:"gray"
                border.width: 1
                Text
                {
                    text:time_scale
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
            }
        }
    
        Component
        {
            id:high
            Rectangle
            {
                width: parent.width
                height: 40
                color:Qt.rgba(0,0,255,0.1)
                z:5
                /*opacity: 0.5 this will also work */
            }
        }
    
        Rectangle
        {
            id:master
            width: parent.width
            height: parent.height/2
            anchors.centerIn: parent
            color: "red"
    
            ListView
            {
                id:ge
                spacing:0
                height: parent.height
                width: parent.width
                model:time
                delegate: comp
                highlight: high
                focus:true
            }
        }
    
    }
    
    
    1 Reply Last reply
    0
    • oria66O Offline
      oria66O Offline
      oria66
      wrote on last edited by
      #2

      @Bhushan_Sure Hello. I don't know your final application, but if you change the height of master component (eliminate the "/2") the problem fix? I test this solution and the change of height was eliminated...

      The truth is out there

      Bhushan_SureB 1 Reply Last reply
      1
      • oria66O oria66

        @Bhushan_Sure Hello. I don't know your final application, but if you change the height of master component (eliminate the "/2") the problem fix? I test this solution and the change of height was eliminated...

        Bhushan_SureB Offline
        Bhushan_SureB Offline
        Bhushan_Sure
        wrote on last edited by
        #3

        @oria66 if i eliminate master height(/2) , then it will take windows height then in that case it is working fine, But i don't have to give window's height, i want some specific height only. Only i case of parent height it is working fine.

        1 Reply Last reply
        0
        • YashpalY Offline
          YashpalY Offline
          Yashpal
          wrote on last edited by
          #4

          Hi! setting clip property of listview to true would eliminate the visibility of unwanted delegate. But, I'm not sure whether this is the correct solution. Clip operation is a costly operation, would impact the performance.

          Bhushan_SureB 1 Reply Last reply
          4
          • YashpalY Yashpal

            Hi! setting clip property of listview to true would eliminate the visibility of unwanted delegate. But, I'm not sure whether this is the correct solution. Clip operation is a costly operation, would impact the performance.

            Bhushan_SureB Offline
            Bhushan_SureB Offline
            Bhushan_Sure
            wrote on last edited by
            #5

            @Yashpal It work's fine for me, Thank you Yashpal :)

            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