Position images in a widget and return to the line on overflow
-
Hello community,
So far I've used a few simple elements of QT and I'm stuck on what I'd like to achieve
To simplify my idea, it would be to put images (16x16 blue squares) vertically aligned in a widget and when it reaches the end of the widget size, the images would be placed in a line below, and so on
I'm sure it's not complicated, but I don't know QT very well. I've already tried the simple grid alignment in the widget and a few other elements, but it didn't work.
Thanks
-
Hi @beautifulcloud
Have a look at:
https://doc.qt.io/qt-6/qtwidgets-layouts-flowlayout-example.html -
Hello @mpergand ,
I believe it's what I need
Tell me if I'm wrong :
- I created a class flowlayout thanks to a recovered code, so a flowlayout.h and a flowlayout.cpp
- In qt design I clicked on "Promote to" and I added the layout flowlayout.h which I then activated
But when compiling the flowlayout header is not found by the ui file
F:\build-Sunfade-Desktop_Qt_6_5_1_MinGW_64_bit-Debug\Sunfade_autogen\include\ui_secondarywindow.h:22: erreur : flowlayout.h: No such file or directory
I added the files in CMakelist and added an include in the source .cpp file
Thanks for your answer
-
@beautifulcloud
I don't know, I don't use Qt 6 or cmake.
There are numerous examples in the Qt folder at:
Qt XX/examples/
You can create a project from these examples in QtCreator:- clik on Welcome tab on the left
- type flowlayout in the search field
- click on FlowLayout example thumbnail
a project is automatically created and see if it works.
-
Hello @mpergand ,
As with the old code I integrated the flowlayout object in my project and I didn't manage to implement it in QT Design, but it does not matter because I left to do it in the source code.
But the flowlayout was what I was looking for so thanks!
-
-