PDA

View Full Version : QTreeView: Creating an animated busy icon whilst loading data



squidge
19th July 2010, 10:56
I have a QTreeView where the contents is loaded from a network. This network can be slow, so I'd like place an animated graphic in the middle of the control to show that the data is being updated rather than the user not knowing when the load is complete. I don't want to disable the control as I want the user to be able to use it whilst the data is being updated. By 'Updated' I mean that new items will be added to the view.

I don't know whether to just have another widget sit in the middle of the control which animates, or to subclass QTreeView and do some drawing in there. The former doesn't lend itself to a layout manager very well (If the window is resized and resizes the QTreeView control, I would have to manually updated the internal animated widget too).

Any suggestions?

aamer4yu
19th July 2010, 12:43
You may use delegates to show the busy animation.
Or -
You can show a QLabel loaded with busy.gif on screen position of the item. I guess you can map the item coordinates to scene coordinates. But you will need to update the label's position if the tree view size changes or is moved.

Subclassing the QTreeView might also be a good idea, since you can easily calculate the items position, and show QLabel at that point. You also wont need to worry about using timer or updates for animation if you go for delegates.