PDA

View Full Version : How to design a thumbnail viewer in QT



MrBeef
19th April 2010, 23:43
I'm trying to design a thumbnail viewer that displays several pixmaps in a grid of some type.

I want it to automatically re-arrange the thumbnails when I resize the window. So far I've tried using a QGridLayout to do this but it doesn't seem like it has the ability to auto-rearrange.

Any suggestions on what Qt objects to use for this purpose? Or are there any good examples to point me to? Thanks!

JohannesMunk
20th April 2010, 03:41
Hi!

This qt-app uses a QGraphicsView. They use it to allow dynamic resizing of the images, when the user clicks on them.
http://qt-apps.org/content/show.php/Picture+Wall?content=106101

What do you mean by auto-arrange? That the number of rows and columns change automatically? I dont know if something like this exists, but writing your own layoutclass that arranges widgets in a line breaking manner should be possible :->

Johannes

MrBeef
20th April 2010, 05:27
Thanks for the reply, I'll check it out.

By auto-arrange I mean that, if I stretch the window to become wider, the images will automatically form a single row across. If I make the window smaller, the images will form several rows as needed with a vertical scroll bar.

A quick QGridLayout example that I made doesn't do that. Thanks again.

Archimedes
20th April 2010, 05:40
What size policy did you use and you didn't got the desired result?

Lykurg
20th April 2010, 07:54
By auto-arrange I mean that, if I stretch the window to become wider, the images will automatically form a single row across. If I make the window smaller, the images will form several rows as needed with a vertical scroll bar.

A quick QGridLayout example that I made doesn't do that. Thanks again.
Have a look for the flow layout example. But if you don't have thousends of items, just react on the resize event and calculate the position of the items yourself in a function. ~ 15 lines of code!