PDA

View Full Version : Difficult:Dynamic Icon size change?!?



nupul
10th April 2006, 05:51
Given data: QListview: length=desktop->width();


Problem statement(s):
1. You are dispaying some icons using Qlistview. The maximum allowed icon size is 48x48. Whenever the user shrinks the size of the window, the icons should also shrink to fit them selves within the viewport. Similarly the icon, should expand only till the max size as mentioned. In no case shall a scroll bar appear...assuming that there is only one row of Icons.

2. (Qlistview height=52 pixels - fixed...can't be changed) Now assume that the maximum icons that can occupy one whole row (the breadth of the desktop screen) is 10. If the user drags another Icon into this widget (thus making the total num to 11) the other Icons should shrink in size to accommodate this extra Icon.

2.1. Alternatively, You are allowed to add the scroll buttons (up & down) but the scroll bar itself should not be shown...i.e. the scrolling should be completely controlled by the buttons implying this, placed at the either end of the widget. Each scroll should be in steps of the icon size (fixed at 48 pixels)

Any answers....

Thanks..

Nupul

wysota
10th April 2006, 09:03
Any specific questions?

A general answer is to change icon size when container size changes and to set an scroll step (its called pageStep) to an appropriate value.

nupul
10th April 2006, 09:17
Any specific questions?

w.r.t what? I've put forth 3 problems!



A general answer is to change icon size when container size changes...


ummm, I knew this is the answer, but I wanted to know how to do it :confused:



and to set an scroll step (its called pageStep) to an appropriate value.


didn't know this, thanks for the pointer...but can i do so without actually displaying a scrollbar, but buttons, as i mentioned...I'd appreciate if you can help me with some code snippet rather than plain text...it'll help me understand better!

wysota
10th April 2006, 09:30
w.r.t what? I've put forth 3 problems!
We're giving hints here, not producing free solutions for every problem. You should first try to do something on your own and then if you have particular problems, ask for help. And we are very strict about it when it comes to academic projects like yours.


ummm, I knew this is the answer, but I wanted to know how to do it :confused:
But you didn't ask how to modify icon size when the container size changes, you just stated what final behaviour you want to have.

You're probably using QListView so I guess you should reimplement QListView::iconSize() or use QListView::setIconSize() from within resizeEvent (or resize() method reimplementation).


didn't know this, thanks for the pointer...but can i do so without actually displaying a scrollbar, but buttons, as i mentioned...I'd appreciate if you can help me with some code snippet rather than plain text...it'll help me understand better!

I don't think a snippet is needed here :) Use QAbstractScrollArea::scrollContentsBy() from within a slot connected to the clicked() signal of those buttons. The only problem is implementing buttons themselves :) If you want to place them on the inside of the view, you can't use layouts but rather use setGeometry() from resizeEvent to move them to appropriate places. When they are to be outside, layouts should be fine, but you waste some space. Of course you have to make sure the scroll bar is hidden.

nupul
10th April 2006, 09:39
We're giving hints here, not producing free solutions for every problem. You should first try to do something on your own and then if you have particular problems, ask for help. And we are very strict about it when it comes to academic projects like yours.


This particular doubt is not concerned with my project. I had seen an app do this once and was just curious if the same could be achieved in Qt! As for trying to do this on my own is concerned....i just didn't know what to try and use to try a solution :D

Thanks!

Nupul