Results 1 to 3 of 3

Thread: make QMovie move while in blocking function call.

  1. #1
    Join Date
    Oct 2011
    Location
    Australia
    Posts
    29
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default make QMovie move while in blocking function call.

    Hello, I want to throw up a status notification while doing a network check which involves blocking system calls and may take some time. The notification will take the form of a message like "doing NW check" and a strobing animation. THis is the code:

    QMovie * strobe = new QMovie( "./strobe.gif" );
    QLabel * label = new QLabel( "Checking Networking ... " );
    QLabel * field = new QLabel();
    strobe->start();
    field->setMovie( strobe );
    systemCheckPage->addRow( label, field );
    repaint();
    qApp->processEvents();
    doNetWorkCheck(); //blocks
    ...

    Problem is - I think - the movie relies on the event loop. Not even the text label is shown. The repaint() and processEventd() dont do sqwat. Is there a better graphics class I could use that works without the event loop or another simple way around this?

    Thanks.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: make QMovie move while in blocking function call.

    To be effective, processEvents() should be called from within the blocking function; in this case doNetworkCheck().
    If there is to much delay in doNetworkCheck(), then maybe you should consider running it in its own thread.

  3. #3
    Join Date
    Oct 2011
    Location
    Australia
    Posts
    29
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: make QMovie move while in blocking function call.

    Thanks for reply.

    Found solution. So yeah I think threading is the general solution here unfortunately. In my case since Im calling executable processes and waiting for return I can use QProcess, and connect the finished() signal to a handler. I had not realized QProcess could be used like this.

    Thanks.

Similar Threads

  1. Replies: 5
    Last Post: 15th August 2010, 21:34
  2. Qt function call in vb.net
    By abghosh in forum Qt Programming
    Replies: 7
    Last Post: 6th March 2010, 17:00
  3. call function as Qstring
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2009, 01:35
  4. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 09:13
  5. Is there a move file to function ?
    By _SamSoft_ in forum Qt Programming
    Replies: 2
    Last Post: 4th June 2007, 19:32

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.