How to display a grid of non-uniform cells ?
-
@raven-worx
Where did you find a good ref for the Masonry algorithm ?@mrjj said in How to display a grid of non-uniform cells ?:
Where did you find a good ref for the Masonry algorithm ?
There are some algorithmns on the web. Basically i looked at various JavaScript implementations and based on them i implemented it in QML/C++.
There are more simple ones and more sophisticated ones available.@SeeLook
The problem with theFlowelement is that it doesn't takes care of the uniform row height. But which could be easily achieved though i guess by setting a fixed height to the items.
But achieving a "filled width" isn't that easy. -
@mrjj said in How to display a grid of non-uniform cells ?:
Where did you find a good ref for the Masonry algorithm ?
There are some algorithmns on the web. Basically i looked at various JavaScript implementations and based on them i implemented it in QML/C++.
There are more simple ones and more sophisticated ones available.@SeeLook
The problem with theFlowelement is that it doesn't takes care of the uniform row height. But which could be easily achieved though i guess by setting a fixed height to the items.
But achieving a "filled width" isn't that easy.@raven-worx
Ok, i did see the java script ones but wanted language neutral explanation but
i guess it a variant of bin packing that is used. -
@raven-worx
Ok, i did see the java script ones but wanted language neutral explanation but
i guess it a variant of bin packing that is used.@mrjj said in How to display a grid of non-uniform cells ?:
i guess it a variant of bin packing that is used.
yes exactly, basically it's bin packing. You can design it really simple or pretty smart. There are numerous ways to implement such layout. Depending on the features desired.
My implementation for example has the ability to stretch a certain item over 2 columns/rows. Making an item more present in the layout.
I hope i can provide the plugin sometime this year. Will make an anouncement in the showcase sub-forum ;)
-
@mrjj said in How to display a grid of non-uniform cells ?:
i guess it a variant of bin packing that is used.
yes exactly, basically it's bin packing. You can design it really simple or pretty smart. There are numerous ways to implement such layout. Depending on the features desired.
My implementation for example has the ability to stretch a certain item over 2 columns/rows. Making an item more present in the layout.
I hope i can provide the plugin sometime this year. Will make an anouncement in the showcase sub-forum ;)
@raven-worx
Oh that sounds helpful.
Is the project on git or still private ?Ok, i hope u get some time.
Thx
-
@raven-worx
Oh that sounds helpful.
Is the project on git or still private ?Ok, i hope u get some time.
Thx
-
@raven-worx
Super
QrwAndroid sounds awesome :) -
@SeeLook said in How to display a grid of non-uniform cells ?:
Maybe
Flowcan suit You?As far as I can see
Flowdoesn't work with a model likeGridviewdoes. -
@Curtwagner1984
And what if to squeezeRepeaterinside theFlow? -
@Curtwagner1984
And what if to squeezeRepeaterinside theFlow?@SeeLook said in How to display a grid of non-uniform cells ?:
@Curtwagner1984
And what if to squeezeRepeaterinside theFlow?I don't know.
Gridviewcreates and destroys delegates as needed. If I'll put a repeater inFlowand I have let's say 500 images, they would all have to be loaded to memory. -
Can you elaborate a bit more about how and what you did, so that I may try it too ?
-
If I were You, I might try something like this:
Flow { Repeater { model: yourData.length Image { source: yourData[index] sourceSize.height: 200 // or other fixed value } } }If
yourDataisQStringListor just QML array of strings, it can be directly set as a model of theRepeater:model: yourDataand accessible inside
Imagethis way:source: modelDataI hope this is some clue for You
-
If I were You, I might try something like this:
Flow { Repeater { model: yourData.length Image { source: yourData[index] sourceSize.height: 200 // or other fixed value } } }If
yourDataisQStringListor just QML array of strings, it can be directly set as a model of theRepeater:model: yourDataand accessible inside
Imagethis way:source: modelDataI hope this is some clue for You
This could work... I'll have to check if it disposes of elements that aren't visible.
-
@SeeLook Looks like the
modelcan be aQAbstructListModelwhich is exactly what I use...
It's interesting, I'll try this out.Other problems are the insert and remove function that
GridViewsupports, as well as theshouldfechmoreandfetchmorefunctions. (implemented inQAbstructListModel)