[Qt-interest] Model/View and animation

Dmitry Nezhevenko dion at inhex.net
Tue Mar 17 19:06:01 CET 2009


On Tue, Mar 17, 2009 at 07:11:43PM +0200, Dmitry Nezhevenko wrote:
> 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.
> 

I mean that it changes only when item's "ShouldBlink" role changes. 

> > 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?
> 

Currently the only way I see (using ItemDelegate) is to call
QAbstractItemDelegate::paint() with some painter and model index of item
that should blink. 

As about implementing directly in QTreeView I'll need to call
QTreeView::drawRow() method with correct ModelIndex.

> > 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.
> 

This means that there is no "hidden" features. I only want to get
something like "animated" icon for item.
 
-- 
WBR, Dmitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090317/b00ed263/attachment.bin 


More information about the Qt-interest-old mailing list