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

醉酒当歌 提交于 2019-12-23 15:41:05

问题


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.

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.


回答1:


Use QProgressIndicator insted of gif animation.

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



来源:https://stackoverflow.com/questions/32636864/qt-load-indicator-by-animated-image-aka-preloader-or-alternative

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!