Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QML ListView individual item spacing

    QML and Qt Quick
    2
    2
    5653
    Loading More Posts
    • 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.
    • B
      Beacon11 last edited by

      Hello.

      I have a ListView with Image delegates. The images can be different sizes, so to space images in the list evenly I was hoping perhaps I could have different spacings for each image depending on that image size.

      In other words, the ListView.spacing property doesn't work since it affects all delegates equally. Is there a way to specify spacing inside the delegates themselves? anchors.topMargin and the like don't seem to work.

      Thanks for your help!

      1 Reply Last reply Reply Quote 0
      • M
        mlong last edited by

        You could make a plain Item (or Rectangle) as a delegate, with the Image as a child item of that item. Then you could adjust the height of the Item itself as needed while leaving your Image (or other contents of the item) their original size.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post