Animated items using delegates
A nasty hack involving a custom delegate, timer events and a signal to inform a view that it needs to repaint itself. It is just a proof of concept.
Perhaps a better example might be Animated items using delegates and movies.
Things that are wrong with this code:
- It starts a timer and never stops it.
- The signal in the delegate is connected to the viewport of the view instead of the view itself (it doesn't work otherwise).
- The delegate simply shifts the normal content of the waiting items and paints a pixmap - it doesn't try to replace or add an icon to existing items.
1 import sys
2 from PyQt4.QtCore import pyqtSignal, Qt, QVariant
3 from PyQt4.QtGui import *
4
5 # Icons used for animation:
6 _icon0_xpm = [
7 "16 16 4 1",
8 ". c None",
9 "s c #cccc00",
10 "x c #ffffff",
11 " c #000000",
12 "................",
13 ". .",
14 ". xxxxxxxxxxxx .",
15 ". x x .",
16 ".. x ssssss x ..",
17 "... x ssss x ...",
18 ".... x ss x ....",
19 "..... x x .....",
20 "..... x x .....",
21 ".... x x ....",
22 "... x x ...",
23 ".. x x ..",
24 ". x x .",
25 ". xxxxxxxxxxxx .",
26 ". .",
27 "................"]
28
29 _icon1_xpm = [
30 "16 16 4 1",
31 ". c None",
32 "s c #cccc00",
33 "x c #ffffff",
34 " c #000000",
35 "................",
36 ". .",
37 ". xxxxxxxxxxxx .",
38 ". x x .",
39 ".. x s s x ..",
40 "... x ssss x ...",
41 ".... x ss x ....",
42 "..... x x .....",
43 