Results 1 to 4 of 4

Thread: launch in a gif via QMovie and QThread

  1. #1
    Join Date
    Jul 2006
    Posts
    37
    Thanks
    6
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question launch in a gif via QMovie and QThread

    Hi,

    I try to launch a throbber (just a gif) during intensive process.

    1) I tried to launch it directly like

    Qt Code:
    1. QMovie movie(":/throbber.gif");
    2. movie.start();
    3. label->setMovie(movie);
    4.  
    5. ...
    6. //intensive process
    To copy to clipboard, switch view to plain text mode 


    The gif doesn't move at all during process and start moving after the intensive process

    2)Using a QThread

    Qt Code:
    1. CThreadMovie::CThreadMovie(QMovie * movie)
    2. {
    3. _movie = movie;
    4. }
    5.  
    6. void CThreadMovie::run()
    7. {
    8. if (_movie != NULL)
    9. _movie->start();
    10.  
    11. exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    I launch with this interface:

    Qt Code:
    1. QMovie * movie = new QMovie(":/throbber");
    2. labelThrobber->setMovie(movie);
    3.  
    4. // create Thread instance
    5. _threadMovie = new CThreadMovie(movie);
    6.  
    7. _threadMovie->start();
    To copy to clipboard, switch view to plain text mode 

    It doesn't work

    So the questions

    What do I do wrong?
    What should I do?

    Thanks to all

    David

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: launch in a gif via QMovie and QThread

    You must not touch widgets in worker threads. Either handle that "intensive process" in a worker thread and deliver results to main GUI thread with signals and slots (or custom events) or call QCoreApplication::processEvents() every now and then in the middle of the "intensive process".
    J-P Nurmi

  3. #3
    Join Date
    Jul 2006
    Posts
    37
    Thanks
    6
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: launch in a gif via QMovie and QThread

    OK

    As we have made all our process in one thread; it's not a simple work to change the complete application to Muti Thread

    So for just running a Gif Is there a simple way (something very light)?

    Thanks

    David

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: launch in a gif via QMovie and QThread

    You must let the application process its events meanwhile you do intensive work which blocks the event loop. So as I said, call QCoreApplication::processEvents() every now and then during the intensive work.
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.