PDA

View Full Version : QTreeWidget



coderbob
21st February 2008, 08:10
When upArrow, downArrow, scrolling etc in applications such as konqueor, Nautilus, Windows explorer, etc there appears to be a mechanism that if you do not spend approx 1 sec on the item as you scroll it will not load the corresponding contents in the view pane.

This stops loading views that will not be seen anyways due to quick scrolling through items in the tree. I have not looked at the QDirModel code yet to see how Qt implemented this functionality and will ultimately look there if I cannot find a simple answer.

So my questions is there any mechanism I can use in Qt to provide the same functionality as stated above. I figured I could use single shot timers to acheive a similar effect but it did not seem like a very clean solution.

Bob

jpn
21st February 2008, 08:19
Yes, you need a timer. Here's a nice way to delay tasks in Qt: http://www.qtcentre.org/forum/f-qt-programming-2/t-searching-in-qlistview-8181.html#15

coderbob
21st February 2008, 09:29
Thank you for the help jpn.

But if someone scrolls down through a tree of lets say 100 entries isn't firing off 100 timers going to be a bit of a system burden?

Depending on the timer lengths some will be expiring as others are created and it will be far less demanding then rendering every un needed widget but still seems a bit system intensive.

Bob

jpn
21st February 2008, 09:38
But if someone scrolls down through a tree of lets say 100 entries isn't firing off 100 timers going to be a bit of a system burden?

Depending on the timer lengths some will be expiring as others are created and it will be far less demanding then rendering every un needed widget but still seems a bit system intensive.
Did you look at Michiel's post? I suggest taking a closer look at it. The whole point is to keep a single timer which gets reset every time something happens. So the timer gets reset every time current index changes and doesn't get fired at all until current index remains same for a pre-defined period, a single timer interval that is.

coderbob
21st February 2008, 09:40
I did but I was in error to miss such a crucial point, I apologize for missing that. I will take a closer look, thank you for pointing that out.

Bob

EDIT: Working like magic in a bottle. Thank you again for pointing out the finer bits I overlooked.