Results 1 to 14 of 14

Thread: Busy Indicator using QProgressDialog??

  1. #1
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Busy Indicator using QProgressDialog??

    I am trying to copy /dev/mem to another location and want a 'busy indicator progressDialog' (in which a fluid moves to and fro in a progress bar) to show that the copying process is going on.

    Qt provides two widgets for showing progress
    1. QProgressBar
    2. QProgressDialog

    if we set both setMinimum and setMaximum equal to zero in 'QProgressBar' then i get the to and fro functionality but although setMaximum and setMaximum properties are available for 'QProgressDialog' too; setting them to zero do not give me the required functionality.

    I hope i made myself clear. Please suggest some solution..

    Following link contains the snippet of the code

    Qt Code:
    1. QProgressDialog progress("Copying files...", "Abort Copy", 0, 0);
    2. progress.setWindowModality(Qt::WindowModal);
    3. progress.setMinimumDuration(0);
    4.  
    5. QObject *parent;
    6. QString temp="checking";
    7. QString program = "dd if=/dev/mem of=/home/usman/copiedFile.dt"
    8. QProcess *myProcess= new QProcess(parent);
    9. QCoreApplication::processEvents();
    10.  
    11. progress.setRange(0, 1);
    12. progress.setValue(0);
    13. progress.setRange(0, 0);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    looking at the QProgressDialog docs...

    Qt Code:
    1. Progress starts at the value set by setMinimum(), and the progress dialog shows that the operation has finished when you call setValue() with the value set by setMaximum() as its argument.
    2. The dialog automatically resets and hides itself at the end of the operation. Use setAutoReset() and setAutoClose() to change this behavior.
    To copy to clipboard, switch view to plain text mode 

    so it looks like this dialog is not ment for showing busy states..

    try this if it works...i am not too sure

    Qt Code:
    1. progressDialog->setBar(bar);
    2. bar->setMinimum(0);bar->setMaximum(0);
    3. progressDialog->show();
    To copy to clipboard, switch view to plain text mode 

    as a last resort u can make your own dialog class .

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Busy Indicator using QProgressDialog??

    Set the range to (0,0) in the first place (before calling setValue) and I think you should obtain what you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Busy Indicator using QProgressDialog??

    setting the value to (0,0) did not solve the problem. And i tried the setBar(QProgressBar *bar) too, suggested by MrDeath, but it also did not result in some thing fruitful.


  5. #5
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: Busy Indicator using QProgressDialog??

    After don't having much luck with QProgressDialog...i now turned to ProgressDialog but encountered another problem.

    I got the to and fro movement of a blue fluid in the progress bar, depicting the busy state, but i want to make the bar filled with blue fluid at the completion of the operation i am performing.

    But problem is that for the busy indicator i need to setMaximum=0. And at the end of process i need to set setMaximum to say 100 and setValue to 100 too.

    When i run my app, the later setMaximum seems to overide the previous setMaximum and as soon as the app runs, the progressBar gives a 100% reading with the blue fluid filled comletely in it, without showing any busy indicatior.

    If i use the waitForFinished() function of QProcess to wait until my task is finished (and then setting the setMaximum=100 and setValue=100) then my app gets frozen and i neither get a busy indicatior nor a blue fluid filled bar.

    Following is the code
    Qt Code:
    1. QObject *parent;
    2. progressBar->setMaximum(0);
    3. progressBar->setMinimum(0);
    4.  
    5. QString program = "dd if=/dev/mem of=";
    6. program.append(lineEdit_saveAt->text());
    7. QProcess *myProcess= new QProcess(parent);
    8. QCoreApplication::processEvents();
    9.  
    10. myProcess->start(program);
    11.  
    12. //if myProcess->waitForFinished() {
    13. progressBar->setMaximum(100);
    14. progressBar->setValue(100);
    15. //}
    To copy to clipboard, switch view to plain text mode 

    Please suggest something. Thanks

  6. #6
    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: Busy Indicator using QProgressDialog??

    setting the value to (0,0) did not solve the problem.
    wysota told you to set the range, not value.
    If i use the waitForFinished() function of QProcess to wait until my task is finished (and then setting the setMaximum=100 and setValue=100) then my app gets frozen and i neither get a busy indicatior nor a blue fluid filled bar.
    make a slot in which you set the progress filled (max = 100, value = 100) and connect QProcess::finished() to it.
    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.

  7. The following user says thank you to faldzip for this useful post:

    qtzcute (13th July 2009)

  8. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    same problem encountered .. in progressDialog setting range or value to 0 is not working .. but its working for QProgressBar ...
    "Behind every great fortune lies a crime" - Balzac

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Busy Indicator using QProgressDialog??

    Quote Originally Posted by qtzcute View Post
    setting the value to (0,0) did not solve the problem. And i tried the setBar(QProgressBar *bar) too, suggested by MrDeath, but it also did not result in some thing fruitful.

    Works for me...

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv){
    4. QApplication app(argc, argv);
    5. dlg.setRange(0,0);
    6. dlg.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. The following user says thank you to wysota for this useful post:

    qtzcute (13th July 2009)

  11. #9
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Busy Indicator using QProgressDialog??

    @falzip
    Thanks..that worked.

    @wysota
    I wasn't using dlg.exec(). Most probably that was the reason. Thanks for helping.

  12. #10
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    why so difficult???
    use
    Qt Code:
    1. QProgressDialog progress(this);
    2. progress.setWindowModality(Qt::WindowModal);
    3. progress.setLabelText("working...");
    4. progress.setCancelButton(0);
    5. progress.setRange(0,0);
    6. progress.setMinimumDuration(0);
    7. progress.show();
    8. //do what u want...
    9. progress.cancel();
    To copy to clipboard, switch view to plain text mode 

  13. #11
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    Quote Originally Posted by Qiieha View Post
    why so difficult???
    use
    Qt Code:
    1. QProgressDialog progress(this);
    2. progress.setWindowModality(Qt::WindowModal);
    3. progress.setLabelText("working...");
    4. progress.setCancelButton(0);
    5. progress.setRange(0,0);
    6. progress.setMinimumDuration(0);
    7. progress.show();
    8. //do what u want...
    9. progress.cancel();
    To copy to clipboard, switch view to plain text mode 
    Did you noticed that this thread is 2 years old and the OP got the answer as well.

  14. #12
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    I know, but his solution is intricate, and lots of people google for "QProgressDialog busy indicator" and hit on this thread.
    So I think it's useful, if there is another working solution, isn't it?

  15. #13
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    well, if you try your code
    1. progress.show();
    2. //do what u want...
    3. progress.cancel();

      You will not see the animation in the progress dialog because the event loop would be blocked util your "//do what u want" is finished.

  16. #14
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Busy Indicator using QProgressDialog??

    no, I use my code in a couple of programs and it works.

Similar Threads

  1. busy progress bar without thread ?
    By npc in forum Newbie
    Replies: 34
    Last Post: 23rd July 2009, 09:29
  2. Replies: 2
    Last Post: 22nd January 2008, 15:15

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.