Results 1 to 3 of 3

Thread: speed of the gif

  1. #1
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default speed of the 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:

    Qt 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. }
    To copy to clipboard, switch view to plain text mode 

    And the cpp of the LoadingWidget:

    LoadingWidget::LoadingWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LoadingWidget)
    {
    ui->setupUi(this);
    var_timer = 0;
    load_gif = new QMovie (":/ImagesMilk/Iconos/zombiewalk.gif");
    ui->label_gif->setMovie (load_gif);
    timer = new QTimer (this);
    this->setWindowFlags (Qt::Window |Qt::CustomizeWindowHint);
    connect (timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start (1000);
    load_gif->start ();
    }

    LoadingWidget::~LoadingWidget()
    {
    delete timer;
    delete load_gif;
    delete ui;
    }

    void LoadingWidget::update (){
    var_timer = (var_timer+1) %4;
    switch (var_timer){
    case 0:
    ui->label_text_loading->setText ("Loading");
    break;
    case 1:
    ui->label_text_loading->setText ("Loading.");
    break;
    case 2:
    ui->label_text_loading->setText ("Loading..");
    break;
    case 3:
    ui->label_text_loading->setText ("Loading...");
    break;
    }
    }
    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: speed of the gif

    Your QMovie requires an event loop to be running, or processEvents() called often enough, so that its frame timing (QTimer) can work. The timer expiry will not be processed until the next time the events are processed after the time has expired.

    Also, at line 20 and 29 you directly call the destructor. This is an unusual thing to do. Normally you would just:
    Qt Code:
    1. delete loadwidg;
    To copy to clipboard, switch view to plain text mode 
    to free the memory in use and let C++ look after destruction.

  3. The following user says thank you to ChrisW67 for this useful post:

    KillGabio (12th February 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: speed of the gif

    code updated thanks for pointing that out i dont know why i call that destructor because I usually just delete them :/

Similar Threads

  1. Scrollbar speed
    By qtnewbi3 in forum Qt Programming
    Replies: 0
    Last Post: 26th July 2011, 19:29
  2. Speed Up TreeView
    By abbapatris in forum Qt Programming
    Replies: 6
    Last Post: 14th June 2010, 19:42
  3. how to speed up the replot?
    By rambo83 in forum Qwt
    Replies: 4
    Last Post: 16th December 2009, 11:51
  4. exception catching speed
    By stefan in forum General Programming
    Replies: 10
    Last Post: 12th November 2008, 19:58
  5. Speed of static app
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2006, 20:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.