[Qt-interest] Model/View and animation

Dmitry Nezhevenko dion at inhex.net
Tue Mar 17 15:08:31 CET 2009


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? 

I see two approaches:

1. Implement it in Model. Use something like timer and emit
dataChanged(affectedIndex) signal every second. View will update
decoration according to Qt::DecorationRole.

2. Implement it in subclassed View. Model will contain just two icons that
may be accessed using different roles. View should use Timer and update
icons some way. 

Any suggestions? First solution looks better, however I think that it's a
bit non optimal to emit dataChanged() signal every second (the only
changed data will be Qt::DecorationRole icon). Also what happens if I will
decide to use animation (so icon will be changed every 0.1 second)?

Maybe some other solution?

Thanks.

-- 
WBR, Dmitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090317/da6566a1/attachment.bin 


More information about the Qt-interest-old mailing list