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. Implement custom QML FlowLayout
Forum Updated to NodeBB v4.3 + New Features

Implement custom QML FlowLayout

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
flowlayoutqmlquickflowlayout
1 Posts 1 Posters 531 Views 2 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.
  • P Offline
    P Offline
    Phoenox
    wrote on 8 Jan 2021, 13:18 last edited by Phoenox 1 Aug 2021, 13:19
    #1

    Cheers everyone,

    I'm looking for some pointers on how to implement a FlowLayout in QML.
    The Flow positioner looked promising, however, it does not fully meet the requirements I have.

    Here is what I want to do:
    I have a couple of items which should be shown like the Flow positioner does it: If there is not enough space in a row, the next items should be displayed in the next row.
    Contrary to the Flow positioner, I would like the items to take all the available space, they should fill the width of the layout.

    So I'd imagine implementing a custom FlowLayout. This layout would check how many items would fit in a certain row based on their minimum/preferred widths. It would then layout the items in this row based on the preferred/maximum widths.

    Example
    Imagine I have the following items with the [minimum/maximum] widths:

    • Item0 [100,200]
    • Item1 [100,200]
    • Item2 [100,200]

    If my FlowLayout had width 150, I would like them to be layouted like this:
    [Item0 width 150]
    [Item1 width 150]
    [Item2 width 150]

    If my FlowLayout had width 250, I would like them to be layouted like this:
    [Item0 width 125][Item1 width 125]
    [Item2 width 200]

    So basically, my questions are:

    • Can this be done with the Flow positioner? My guess would be no, because an Item in a Positioner only has a width, and I would need both a minimumWidth and a maximumWidth.
    • How would I start implementing a custom QML layout? I've looked at the source code of the ColumnLayout for inspiration, but the QQuickLayout which I probably have to implement is private.
    1 Reply Last reply
    0

    1/1

    8 Jan 2021, 13:18

    • Login

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