[Qt-interest] Model/View and animation

Scott Aron Bloom Scott.Bloom at sabgroup.com
Tue Mar 17 19:08:04 CET 2009


> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Dmitry Nezhevenko
> Sent: Tuesday, March 17, 2009 10:12 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Model/View and animation
> 
> On Tue, Mar 17, 2009 at 12:56:04PM -0400, Paul Miller wrote:
> > Dmitry Nezhevenko wrote:
> > > Hi. I'm learning how to add some kind of animation to TreeView
based
> > > on Qt Model/View architecture.
> > >
> > > I've some kind of two-column tree that contains text
> > > (Qt::DisplayRole) and icon (Qt::DecorationRole). Now for some
> > > external event I want to "highlight" some item by using blinking
> > > every second icon. What is the best way to implement such
blinking?
> >
> > Is your model really changing every second, or are you just trying
> > call attention to it in the view for some reason?
> 
> No. Currently model just changes once to indicate that something
happens.
> 
> > If your model isn't really changing, I'd avoid the model-based
approach.
> > If you just have certain items you want to blink for some reason and
> > the underlying data isn't changing, the "right" thing would be
> > sticking a timer on your view and have your delegate do the updates.
> 
> So third solution is to do timer-based stuff in deletgate. Any way to
> "invalidate" state of just single QModelIndex so it will be repainted?
> 
> > Maybe you could describe in more detail why your item(s) are
blinking?
> 
> Blinking icon is _just_ notification that user should look to it.
Nothing
> more.
> 
> --
> WBR, Dmitry

The problem with the delegate based approach is the fact that a delegate
can NOT, or (at least I never got it to work :() trigger a paint event.

Where I used this... I had a model representing multiple file processing
and downloads...

So in my table, the first column was an animation representing that the
current file was being worked on...

In the model, ideally all that its data for column 1 would be a
"downloading/processing/stopped" enum..

And in the view, when a datachanged for column 1 occurred, it would
animate appropriately..  either through a delegate or in the view
directly.

I never did get my ideal situation to work...

What I wound up doing, is putting the timer into the model, have it
return the proper "icon" for the modelindex's decoration role, and emit
a datachanged on timed event.

With 100-200 rows visible.. I never really hit performance issues.

BTW.. my client has agreed to let me put that portion of the code into
the open source world, so in the next week or so, I will be doing
that...

Scott






More information about the Qt-interest-old mailing list