Skip to content

Add large image grid example #12481

Description

@sandreas

We'd like to have an example in Slint that shows a very large ("inifinite") grid of thumbnail images and demonstrates how to make such a grid scale. This can be built with a custom slint::Model and a ListView. We've done that before and could recycle some code there.

Original Description (was "Async lazy image loading")

I would love to have a component LazyImage for memory efficient image loading in long lists, that could be used like shown below. The idea is to keep only the images in memory that are visible on screen or with a defined offset and keep the whole visible/loaded/invisible/unloaded logic hidden. This might require a change in the renderer. I can think of something like this:

LazyImage {
    uri: @pathuri("/path/to/image.jpg");
    placeholder: @pathuri("/path/to/placeholder.jpg");
    preload-margin: 100px;
    auto-unload: true;
    loaded() => {
       //
    }
}

Explanation:

  • uri should be a string, not ImageData to keep the footprint low, @pathuri converts a local path to a valid uri
  • placeholder is an image, that is shown while the image is loading or on error
  • preload-margin is the offset of the visible screen, when the image should start to load (x and y direction) - I think length values would be great to have, because percentage would be supported as well
  • auto-unload frees the memory, as soon as the image leaves the visible area / offset - maybe this could be left out in favor of an lrucache solution
  • loaded() - callback, when the image has been successfully loaded - could get ImageData as parameter, maybe error() and unloaded() callbacks would also be nice.

Later it might be possible to add group and group-size properties to determine how many images can be held in cache for a group. A group-size of 5MB would cache 5MB images before cleaning up the oldest data within the actual group.

This feature has already been discussed and related feature requests exist, that may enrich the discussion, but go in a different direction - I think that my approach is much more intuitive and less prone to errors.

Product Impact

I'm trying to build slint in a low memory embedded device, while still having to provide image listings with pagination or infinite scroll.

Activity

  1. added
    need triagingIssue that the owner of the area still need to triage
    on Jul 14, 2026
  2. added theissue type on Jul 14, 2026
  3. tronical commented on Jul 27, 2026

    @tronical
    Member

    We've had a few requests like this and for one of our customers we built a component that acts as a grid for images that can contain thousands of images (thumbnails). This can be built on top of Slint by using a custom model and a ListView. We should add such an example to Slint itself that shows how to do this.

  4. added
    a:demosDemos and examples (mF,bO)
    and removed
    need triagingIssue that the owner of the area still need to triage
    on Jul 27, 2026
  5. changed the title [-]Async lazy image loading[/-] [+]Add large image grid example[/+] on Jul 27, 2026
  6. tronical commented on Jul 27, 2026

    @tronical
    Member
  7. sandreas commented on Oct 9, 2026

    @sandreas
    ContributorAuthor

    @tronical
    @michneaionuc

    Just as a reminder, this would be pretty important for my project... a small hacked together example would be enough to have a start.

    Maybe I could find the time for a PR to help out with this.

    As an addition I could think of a generic callback for EVERY other component:

    • preload()
    • unload()
      where preload is called, if the component starts being visible and unload when no longer visible. This way every component could be lazy-loading. Paired with the preload-margin, it could be very helpful saving resources. Method wise it could also be onRender - onUnload or even willAppear...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:demosDemos and examples (mF,bO)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions