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] ListView to show variable width images.
QtWS25 Last Chance

[SOLVED] ListView to show variable width images.

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

    I'm making an application that shows images using ListView and want to change the width of the delegate by the size of each image. code is like the below

    @
    Component {
    id: mydelegate
    Item {
    id: myitem
    width: 70
    height: 100
    Image {
    id: myimage
    width: myitem.width; height: myitem.height
    fillMode : Image.Stretch
    asynchronous: true
    source: <some url>
    onStatusChanged: {
    if( myimage.status === Image.Ready )
    if(sourceSize.width > sourceSize.height)
    myitem.width = 120;
    }
    }
    }
    }
    @

    the result is, the image size varies by the 'sourceSize' but the images are overlapped. but after the images that scrolled in are not overlapped.
    what's the problem?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      coldmund
      wrote on last edited by
      #2

      The reason is the animation on ListView. It works after I changed the size after the animation.

      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