[Qt-interest] QProgressBar in a QStyledItemDelegate

Matt Broadstone mbroadst at gmail.com
Tue Aug 4 21:21:43 CEST 2009


Hi,
  I've read a number of great articles on drawing a QProgressBar by
hand in an item view (not to mention the example in the torrent
example), however I had a slightly more advanced example in which this
was not possible. I have a QListView of items in a collection of
tasks, and as each task is run (only one at a time) I want a progress
bar displayed for the task. The kicker here is that I also want
support for indeterminate progress bars (the "barber's pole" look when
min/max range is set to 0). As far as I was able to determine (and
from discussions with kdepepo on #qt on freenode) this is simply not
possible without an actual widget, as the style needs to register the
widget and call update on it according to an animation timer. What to
do.. well instead I created a QProgressBar widget in my delegate and
in the paint method just move it to the correct coords based on
whether the index is the "active" task. This worked fine, though
perhaps a bit inefficiently, on Mac but as soon as I ran the code on
Windows I had all sorts of crashes. Can anyone think of a better
solution to this problem? Obviously drawing it myself would be ideal,
but I just can't see how that's possible.

Thanks!
  Matt Broadstone



More information about the Qt-interest-old mailing list