1

I need some help with my QT .ui source files for my project....I am trying to have a .gif animated image displayed and just looped where I have the property "pixmap" (hashcoinani)...For some reason it is not displaying and I cannot figure out how to make it display with just the .ui files, Any help would be greatly appreciated! hashcoinani is set as a resource in the .qrc file as hashcoin.gif as well.......Im so lost!

     <widget class="QLabel" name="coinimage">
     <property name="styleSheet">
      <string notr="true"/>
     </property>
     <property name="text">
      <string/>
     </property>
     <property name="pixmap">
      <pixmap resource="../hashcoin.qrc">:/icons/hashcoinani</pixmap>
     </property>
     <property name="scaledContents">
      <bool>false</bool>
     </property>
     <property name="alignment">
      <set>Qt::AlignCenter</set>
     </property>
     <property name="margin">
      <number>-2</number>
     </property>
    </widget>
carsenk
  • 11
  • 3
  • possible duplicate of [GIF animation in Qt](http://stackoverflow.com/questions/3248243/gif-animation-in-qt) – deGoot Apr 30 '14 at 02:03
  • That is entirely different....That is for the C++ code...I am looking to get it to display the GIF just inside of the .ui file such as changing pixmap to something different or the whole widget? – carsenk Apr 30 '14 at 03:11
  • 1
    The UI file is just used as an intermediate/design format. Qt will generate C++ code based on the design in the UI file anyhow, so I don't see why the solution in the link above won't work for you. Unfortunately, `movie` is not a [property of QLabel](http://qt-project.org/doc/qt-4.8/qlabel.html#properties), so I don't think it can be set directly through the UI designer. You're right, though, that this does not directly address your question. – deGoot Apr 30 '14 at 03:30
  • So basically I will have to add some C++ code in the gui.cpp file? Or would it have to go in all the files including headers? I just want the .gif to display and loop thats all, I feel like thats a lot of work to just have a .gif display and play...lol – carsenk Apr 30 '14 at 04:24
  • deGoot if you think you can help me, submit a commit to the github to fix this to display http://github.com/carsenk/hashcoin – carsenk Apr 30 '14 at 04:26

1 Answers1

2

This can't be done in UI designer. You need to get the animated .gif into a QMovie, and then set that on the label using setMovie. You need some C++ code. The designer only goes so far.

Since both Qt framework and Qt Designer are open-source, you could modify both to provide this functionality. It probably would be a day's job.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313