February 12, 2012

KillGabio KillGabio
Lab Rat
41 posts

Speed of gif

 

Hi guys!

This is a very simple question. I have a QLabel with a QMovie that reproduces a .gif… The thing is that I dont know how to show it smoothly, I mean the gif shows perfectly but it`s like “stucking”. I tried increasing the speed but that doesn`t change anything…here is my code:

  1.     int main(int argc, char *argv[])
  2.     {
  3.     QApplication a(argc, argv);
  4.     LoadingWidget *loadwidg = new LoadingWidget ();
  5.     loadwidg->show ();
  6.     qApp->processEvents ();
  7.     QApplication::setStyle (new IconSize ());
  8.     QCoreApplication::addLibraryPath (".");
  9.     MainWindow mainWin;
  10.     ajustarPreferenciasVentanaPrincipal (&mainWin);
  11.     //----------------------------------------------------------
  12.     //-----------------CONTROLADOR------------------------------
  13.     //----------------------------------------------------------
  14.     //some not interesting code
  15.     //----------------------------------------------------------
  16.     //-----------------FIN CONTROLADOR--------------------------
  17.     //----------------------------------------------------------
  18.     if (handler >= 0 && aux ==0 && capacidad >0){
  19.     mainWin.setHandler (handler);
  20.     loadwidg->~LoadingWidget ();
  21.     mainWin.show();
  22.     return a.exec();
  23.     }else{
  24.     if (capacidad == 0){
  25.     QMessageBox::critical (0, QString ("NO MORE REGISTERS TO STORE DATA"), QString ("No quedan más registros para guardar información fiscal\n\nNo se podrá realizar ninguna operación\nrelacionada con el controlador."), QMessageBox::Ok);
  26.     }else QMessageBox::information (0, QString ("NO FISCAL PRINTER"),QString ("No se ha encontrado el controlador fiscal\nconectado, no se podrá facturar"));
  27.     mainWin.setHandler (-1);
  28.     mainWin.show ();
  29.     loadwidg->~LoadingWidget ();
  30.     return a.exec ();
  31.     }
  32.     }

Thank you all in advance… Maybe its my slow computer, maybe its something i cant change…BTW QSplash window does not work for me, its not a solution :P

5 replies

February 12, 2012

Jake007 Jake007
Robot Herder
248 posts

Anything less than 40 ms should be okay.
Otherwise, gifs are pretty slow, so it might be computer ;).
Can you upload a test gif to see the result?

 Signature 

——————————————-
Code is poetry

February 12, 2012

KillGabio KillGabio
Lab Rat
41 posts

http://postimage.org/image/e8qj234cx/

thats the gif..I think it is more than 40ms…The thing is that I think that the load of the main is delaying the gif

February 12, 2012

Jake007 Jake007
Robot Herder
248 posts

Try creating a separate thread for doing all the loading, and in the main thread display only gif ( all in loadingWidget).
Otherwise, the delay is exactly 40ms, and it runs smoothly if I open it normally.

 Signature 

——————————————-
Code is poetry

February 12, 2012

KillGabio KillGabio
Lab Rat
41 posts

I`ll try that approach

February 12, 2012

KillGabio KillGabio
Lab Rat
41 posts

Hi i think im having some problems understanding how to use the threads to my benefit….

I`ve changed my main like this:

  1. #include <QtGui/QApplication>
  2. #include <QObject>
  3. #include "waitthread.h"
  4. #include "loadthread.h"
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     QApplication a(argc, argv);
  9.     QApplication::setStyle (new IconSize ());
  10.  
  11.     LoadThread * load_thread = new LoadThread ();
  12.     WaitThread * wait_thread = new WaitThread ();
  13.  
  14.     QObject::connect (load_thread, SIGNAL(load_finished()), wait_thread, SLOT(loading_finished()));
  15.  
  16.     load_thread->start ();
  17.     wait_thread->start ();
  18.  
  19.     return a.exec ();
  20. }

the loadthread.cpp:

  1. LoadThread::LoadThread()
  2. {
  3.     mainWin = new MainWindow ();
  4. }
  5.  
  6. void LoadThread::run (){
  7.     //--------------------do some stuff
  8.     emit load_finished ();
  9.     mainWin->show ();
  10. }

And the waitThread.cpp

  1. #include "waitthread.h"
  2.  
  3. WaitThread::WaitThread()
  4. {
  5.     loadwidg = new LoadingWidget ();
  6.     loadwidg->show ();
  7. }
  8.  
  9. void WaitThread::run (){
  10. }
  11.  
  12. void WaitThread::loading_finished (){
  13.     loadwidg->close ();
  14.     delete loadwidg;
  15.     this->terminate ();
  16. }

Somehow..the mainWin doesnt show and the loadingwidget neither

————EDIT
My bad loadingWidget is shown.

——EDIT 2

found my first mistake the mainWin must be shown in a different method otherwise the thread finishes when run finishes

 
  ‹‹ How to use a special qm file?      [Solved]QSortFilterProxyModel dont find in the "folder" ››

You must log in to post a reply. Not a member yet? Register here!