3

I have searched some solution for my problem and nothing... I'm using a QMovie with a GIF animation in one QLabel for a loading status, ok? It's simple and i learned in this link: GIF animation in Qt, this works perfectly when i open a menu, for example, than owns one label and i put the QMovie in a QLabel of that menu.

My problem now is, i made a specific UI for loading status, when i know than some UI will be slow to open, i would show my loading status UI and when the UI ends to open i would close my loading status UI. In this loading status UI i puted one QMovie (GIF animation) and a simple QLabel written 'Loading...', very simple, right? Buuuut, when i use this specific UI, the QMovie does not work. In fact it does not stay in looping... See, when i use the QMovie in the UI than i am opening, the QMovie stays in looping.

My english is not so good, but do you understand my problem? =/

I'm using the same code of the link:

this->m_pMovie = new QMovie(":/ui/images/my_image_loading.gif");
this->m_pMovie->setScaledSize(QSize(50, 50));
this->ui->labelImageLoading->setMovie(this->m_pMovie);
this->m_pMovie->start();

Someone know about that?

Thank you...

Community
  • 1
  • 1
Adriano Leal
  • 316
  • 1
  • 5
  • 20

1 Answers1

3

Everything looks fine in how you are using the QMovie. This is just a guess, but I'm wondering if your QMovie is not being updated because the GUI thread is too busy. If you have a UI that is slow to load, that slowness might be because it is consuming a lot of processing on the GUI thread. This is the same thread that is trying to update your QMovie. The result: your QMovie is never updated because it is dependent upon the same GUI thread to get its updates painted.

If there is anywhere in the UI loading process where you could put a few calls to QApplication::processEvents(), that would get the movie to update. But it might be choppy.

Otherwise, there is really not much you can do except try to find a way to make those UIs load faster. (Separate them into different windows, simply the layouts, break into tabs that load as-needed, etc.)

Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
  • I understood @Dave... I really had used QApplication::processEvents(), but forgot to write here. Well, using processEvents() methdos, my QLabel with QMovie is showed but the animation stays static. But now i understand why... Because new UI than i am opening and my loading status UI are in the same thread, GUI thread, right? Thanks for your explanation! I will search some another solution for this, but i believe than will not be possible to use my GIF for loading status, because other problem is if i to open another thread i will not can to paint in the UI too... – Adriano Leal Dec 13 '11 at 18:38
  • One solution would be to spawn an entirely new `QProcess` that launches a "waiting..." application. Then kill the process once the UI is loaded. Then you have two GUI threads (on two different processes). This invites its own problems, of course, and is a bit weighty. But it might work if there is no way to shorten the load time of the main UI. – Dave Mateer Dec 13 '11 at 19:01