Re: photo thumbnail viewer
I 'd suggest to go with QGraphicsView.
When you need to scale many items, just scale the graphics View and everything inside will be scale accordingly.:)
Re: photo thumbnail viewer
Quote:
Originally Posted by
yogeshgokul
When you need to scale many items, just scale the graphics View and everything inside will be scale accordingly.:)
In that particular case scaling the whole scene makes no sense. But you can call all items with a scale value, draw them new and then rearrange the items in the view:
- Status: scale by 20%
- calculate the new with of the item (according also to the width of the view)
- call all items with 20% and the new calculated width (!= width of the picture)
- in the items draw method draw the picture and the gray border
- then rearrange the items in the view
voila!
Re: photo thumbnail viewer
I'd go for QListView. Unless you want some wacky animations, there is nothing Graphics View can give you here.
Re: photo thumbnail viewer
If I may, I would say that QGraphicsView is not adapated to your case, except for scaling functions, since you will have a single row and propably need to move your items often.
Why not making your own widget and use an array of QLabel, displayed on an QHBoxLayout with spacers? You can overload the resize event to scale the images, if it dos not do it automatically with the strench option and provide an empty label item.
Good luck
S.Cascio
Re: photo thumbnail viewer
Quote:
Originally Posted by
scascio
If I may,
Of course you can, we are open minded and everybody is free to speak!
Quote:
I would say that
QGraphicsView is not adapated to your case, except for scaling functions, since you will have a single row and propably need to move your items often.
With a QListView you can scale the items also quite easy using a custom delegate or simple use the gridsize and iconSize property. (I haven't thought of that in my first post)
Quote:
Why not making your own widget and use an array of
QLabel, displayed on an
QHBoxLayout with spacers? You can overload the resize event to scale the images, if it dos not do it automatically with the strench option and provide an empty label item.
If the items change a lot (I guess it will be the case, if it is used like a folder preview) that solution has a bad performance.
Quote:
Originally Posted by
wysota
I'd go for QListView. Unless you want some wacky animations, there is nothing Graphics View can give you here.
You also can make some nice and pleasing animations with Graphics View :D
Ok, I was prejudiced because I have to do a similar work in some weeks and I have decided to use graphics view. This is because I want to display some "image buttons" beneath the pictures for rotating, editing etc. And if you alter the first question for this points, do you would still use a list view? Which means you have do deal with a custom delegate and with e.g pressed(const QModelIndex&) in conjunction with QCursor::pos() to determinate if a modifying button was pressed. Or would there be an other possibility?
Thanks
Re: photo thumbnail viewer
Yeah, thats kind of where I'm at. The QListView seems like the most straight forward but is probably the least flexible in terms of customizing the view. I like the idea of using a QGraphicsView and in that rite I'm a bit biased too, but it's certainly a more complex implementation especially when it comes to layout.
I have a widget already implemented using the flow layout example (http://doc.trolltech.com/layouts-flowlayout.html) in a scroll area where the thumbnails are widgets I'm painting. That works alright but the flow layout, which is really similar to the QListView, dictates the placement of the thumbnails... that is unless I put placeholder widgets/items in there to simulate a grid.
I also have a simple QGraphicsView implementation, but with no real grid system. I posted the code for that a while back when I started thinking about this problem http://www.qtcentre.org/forum/f-qt-p...iew-15739.html
The graphics view allows you to draw the grid on the background plane which is enticing, and you can add nice delighters like animations fairly easily. Its just managing that darn layout.
Anyway, it seems like a pretty equally weighted decisiion, they could all certainly work. I'm sure I'll be back for more questions but hopefully I can bug my boss into letting me post the source for the widget for you guys to tear apart
Re: photo thumbnail viewer
Quote:
that is unless I put placeholder widgets/items in there to simulate a grid.
Have you also considered using a QGridLayout?
Re: photo thumbnail viewer
If you don't want to do the layout in a Graphics View by your own, even if it's not so complicated, QGraphicsGridLayout/QGraphicsLinearLayout could be an option for you.
1 Attachment(s)
Re: photo thumbnail viewer
Hello to everybody!
I have just registered today and it is 2 months since I am trying with Qt 4.5 in-depth... but very happy with Qt!
Sometimes I feel rather alone investigating... :confused: That's why I'm here!
My need is very close (thumbnails viewer similar to lightroom) to chezifresh.
I decided to implement it with qgraphicsgridlayout (thumbnail matrix 5x5), and I am progressing fine but slow..., nevertheless some issues have appeared to me:
1) I can not display the thumbnails without any separation among them (as in lightroom).
Qtgraphicsgridlayout performs it bay itself.
Is there any bug? I have played with Qt functions but no good results.
2) When moving images with my implementation of dnd, the initial thumbnail separation varies and rendering after scene.update is not clean.
It would be nice to discuss these topics with somebody! :)
Re: photo thumbnail viewer
who can share this code? :(
Thanks
Re: photo thumbnail viewer
there are examples and demos in the qt install. why not look at those?
Re: photo thumbnail viewer
Here's essentially what I decided on. In general its a QListView or QListWidget (depending on if you want to write your own model, which is good if you have multiple views, ie. list view and icon view). I also use a QStyledItemDelegate to draw the items the way I want. I'm drawing the thumbnail and the text below it as well as a rounded focus rectangle instead of the default stippled line rect.
Code:
def __init__(self, parent=None):
self.
setIconSize(QtCore.
QSize(160,
90)) # or setGridSize self.
setResizeMode(QtGui.
QListView.
Adjust) # re-lays out the items on resize self.
setLayoutMode(QtGui.
QListView.
Batched) # does the layout with a timer for better performance self.setWrapping(True) # wraps the items to the next line so theres no horiz scrollbar
self.setDragEnabled(True) # in case you want drag and drop
self.setSpacing(1) # spacing between each item, buggy in Qt < 4.7 but works with small #'s