Results 1 to 9 of 9

Thread: QProgressDialog stucks

  1. #1
    Join Date
    Sep 2008
    Posts
    43
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QProgressDialog stucks

    Hey everyone I want to use a progressdialog in busy mode to run a process

    heres the code:

    Qt Code:
    1. QProcess *installproc = new QProcess(this);
    2.  
    3. QProgressDialog progress("Installing Package...", "Cancel", 0, 0, this);
    4. progress.setRange(0,0);
    5. progress.setWindowModality(Qt::WindowModal);
    6. progress.exec();
    7.  
    8. installproc->start(InstallPkgCom);
    9.  
    10. if (installproc->waitForFinished())
    11. {
    12. progress.close();
    13. }
    To copy to clipboard, switch view to plain text mode 


    the problem is that the dialog isnt closing with the process is finished..
    iv noticed that if i dont press cancel or do anythink on the dialog for about 10-15 secs, and then press cancel, the dialog closes and the process is finished

    so basically the process is running just fine even after the dialog shown up, but the dialog refuses to close when the process is finished.

    p.s sorry for my english :P
    Last edited by Mystical Groovy; 2nd October 2009 at 18:10.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    you have to process events now and then (see QCoreApplication::processEvents()) if there is no (other) event loop processing

  3. #3
    Join Date
    Sep 2008
    Posts
    43
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    thanks for your answer,

    i cant get it to work, i run qApp->processEvents();/QCoreApplication->processEvents();

    before and after i call the qprocess, and ive also tried to run the processevents function before and after the qprogressdialog but it wont work,

    any example code? xD

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProgressDialog stucks

    don't use waitFor* methods where you don't have to because they are blocking - as their names say - they're just waiting and doing nothing (your whole application is just waiting) until something is done. Create progress dialog on a heap and connect QProcess::finished() with QProgressDialog::close() and don't use waitForFinished() so in between your applicantion can process events.

    P.S. And I'm not sure but you can set WA_DeleteOnClose attribute to the QProgressDialog...
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Sep 2008
    Posts
    43
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    i dont want to create new slots and staff so ill use the standart system() function

    code ive used but its no working:
    Qt Code:
    1. QProgressDialog progress("Installing Package...", "Cancel", 0, 0, this);
    2. progress.setRange(0,0);
    3. progress.setWindowModality(Qt::WindowModal);
    4. qApp->processEvents();
    5.  
    6. while(progress.exec())
    7. {
    8. system ( InstallPkgCom ); //install package
    9. }
    10.  
    11. progress.close();
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    during the execution of system() the calling thread "pauses" - you can't show a QProgressDialog nor interact with it during that time. So use QProcess instead.

  7. #7
    Join Date
    Sep 2008
    Posts
    43
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    well ive tried to do ti with byconnecting qrocess::finished to QProgressDialog::close()

    but it says:
    Qt Code:
    1. Object::connect: No such signal QProcess::finished()
    To copy to clipboard, switch view to plain text mode 

    heres my code:
    Qt Code:
    1. QProcess *installproc = new QProcess(this);
    2. connect( installproc, SIGNAL(finished()),
    3. this, SLOT(processFinished()) );
    4.  
    5. installproc->start(InstallPkgCom);
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProgressDialog stucks

    you can check in docs that it is: void finished ( int exitCode, QProcess::ExitStatus exitStatus )
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  9. #9
    Join Date
    Sep 2008
    Posts
    43
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProgressDialog stucks

    thank you all for your help i did it!

    Qt Code:
    1. progress->setLabelText("Removing Package...");
    2. progress->setRange(0,0);
    3. progress->setWindowModality(Qt::WindowModal);
    4.  
    5. QProcess *removeproc = new QProcess(this);
    6. removeproc->start(RemovePkgCom);
    7. connect( removeproc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(removeProcessFinished()));
    8.  
    9. progress->exec();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Busy Indicator using QProgressDialog??
    By qtzcute in forum Qt Programming
    Replies: 13
    Last Post: 6th September 2011, 11:31
  2. How draw border in QProgressDialog?
    By kamlesh.sangani in forum Qt Programming
    Replies: 0
    Last Post: 5th June 2009, 11:32
  3. How to use a file to setup a QProgressDialog, Thanks
    By HelloDan in forum Qt Programming
    Replies: 20
    Last Post: 22nd February 2009, 07:55
  4. Replies: 2
    Last Post: 22nd January 2008, 15:15
  5. How to show QProgressDialog without cancel button
    By rajesh in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2007, 09:53

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.