0

I am trying to create a grid layout of images kind of like how google images does it.

I want to add fixed sized images left to right, top to bottom but I am having trouble is figuring out when adding another image to a row would make it not fit and then decide that that images should be placed in a new row.

Also when the window resizes it should move images into/from rows based on how many it can fit in.

Ive got a scroll area with a grid layout in it which is fine if I know what can fit, but I can't figure out how to make it move items if say the window width is shrunk, and say an item needs to be moved down 1 row which moves other etc.

VangardMk
  • 45
  • 2
  • 9

1 Answers1

2

Assuming you are using QWidgets I'd suggest you to use QListView which does the layouting for free, if you want more control on how items are displayed use a QItemDelegate. For QListView the view mode should be set to QListView::IconMode so that you have a grid of items and not a list.

But if you are using QtQuick things are much easier, a GridView with Image delegates would do what you want really quickly and using GPU power to build you UI.

  • Cool thanks, I've messed around with QListView and it does exactly what I need. I'll have to look int QtQuick, I've never done anything with it. Im currently doing my layouts in Qt Designer. I'm pretty new to qt so thanks for the advice! – VangardMk Apr 13 '16 at 19:30