Results 1 to 3 of 3

Thread: Really need a way to process events!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs down Really need a way to process events!

    QApplication::processEvents() or QApplication::processEvents(QEventLoop::AllEvents) doesn't seem to work at all with me for an unknown reason.
    I have a void function that executes some commands and another one that updates the progressbar while the commands are executed, which can take a little time to execute. So the code looks like:
    Qt Code:
    1. //void function that executes the commands:
    2. update_bar("Executing command one",0);
    3. system("command1");
    4. update_bar("Executing command two",25);
    5. system("command2");
    6. ..
    7. ..
    8. update_bar("Done",100);
    To copy to clipboard, switch view to plain text mode 
    the update_bar function is:
    Qt Code:
    1. void update_bar(QString txt, int value){
    2. ui->progressBar->setValue(value);
    3. ui->progressBar->setFormat(txt);
    4. QApplication::processEvents(QEventLoop::AllEvents);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Unfortunately, while I am setting the value and the format of the progressbar 5 times (at 0,25,50,75 and at 100%), when calling the update_bar function, the progressbar only updates at 50 and 100%, skipping the 0,25 and 75% and their texts..


    QApplication::processEvents is the second time that makes me dizzy on how it works...

    Is there anything available that is more efficient, or do you have to suggest an other way of using this function so as to update?
    Last edited by wysota; 20th May 2011 at 21:45.
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

Similar Threads

  1. ActiveQt out of process control sends no events
    By UweS in forum Qt Programming
    Replies: 0
    Last Post: 16th May 2011, 14:08
  2. Replies: 0
    Last Post: 6th August 2010, 11:01
  3. How to communicate Qt Process with non-qt process
    By nrabara in forum Qt for Embedded and Mobile
    Replies: 9
    Last Post: 15th February 2009, 21:01
  4. Pass custom events to another process
    By TTGator in forum Qt Programming
    Replies: 9
    Last Post: 14th January 2009, 22:02
  5. Replies: 1
    Last Post: 13th September 2008, 14:45

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.