c++qtqt5.4

Qt load indicator by animated image (aka preloader) or alternative?


I want to display an animated loader image on my table view while loading. The screenshot below shows an impression.

I have used an animated gif for that, displayed by setStyleSheet as centered background image.

Loader image

I face two issues:

  1. The gif is displayed, but not animated. Is it possible to display an animated gif as background image (via stylesheet)? Remark: In general an animated gif is possible as shown in Qt - How to show gif(animated) image in QGraphicsPixmapItem but there seems to be no animated gif with style sheets Animated Gif static in QStyleSheet
  2. I have problems to clear the image once loading is done. If I clear the stylesheet with setStyleSheet("") then it is still displayed. The only trick working for me is to override it as 1 pixel transparent image

Is there a solution to those issues or even a better approach (overlay widget? / specialized Qt widget for that)?

(My code exampled with Qt 5.4 / Win7)


Edit: https://stackoverflow.com/a/26958738/356726 shows how such a gif can be animated, but I have no idea to use that in such a kind of overlay / background style.


Solution

  • Use QProgressIndicator insted of gif animation.

    PS: it says that it Qt4, but it works with Qt5.