Results 1 to 6 of 6

Thread: qprogressDialog

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default qprogressDialog

    hi, I'm trying using QProgress dialog but the problem is that the dialog appear, the operation is completed (I can see the result), and dialog is again opem and progress bar have to start again;why? thanks
    Qt Code:
    1. //steps*100=6400; I choose a casual number (can it be ok?)
    2. LongOperationTodo ();
    3. myProgressDialog* progress = new myProgressDialog (steps*100, this, "progress", TRUE );
    4. progress->setMinimumDuration(1);
    5. for ( int i = 0; i < steps*100; i++ ) {
    6. progress->setProgress( i );
    7. qApp->processEvents();
    8. if ( progress->wasCanceled() )
    9. break;
    10. }
    11. progress->setProgress(steps);
    To copy to clipboard, switch view to plain text mode 
    Regards

  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: qprogressDialog

    The way you are using the progress dialog is a bit wrong. You need to 1) call QApplication:rocessEvents() and 2) advance the progress bar DURING the long operation, not after it.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qprogressDialog

    I call qApp->process().....but how to call progress DURING? LongOperationTodo (); is a function that call other function; during want mean before??? so I think It'll the same...i'm confused...
    Regards

  4. #4
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qprogressDialog

    hi, my problem is this: I call render pixmap and it take a long time; where do I have to call processEvents? Every examples I saw, insert it in a for; but I haven't it....thanks

    Qt Code:
    1. mainform::render() {
    2. qApp->processEvents();
    3. widget->renderPixmap()
    4. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  5. #5
    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: qprogressDialog

    Quote Originally Posted by mickey
    hi, my problem is this: I call render pixmap and it take a long time; where do I have to call processEvents? Every examples I saw, insert it in a for; but I haven't it....thanks
    Yes, that's the intended usage. There are sometimes lengthy tasks (like calculating of something and so on) which prevent the execution from returning to the application's event loop and so the application cannot process it's move/update/whatever events coming from the underlying system. This is what makes the application unresponsive during a lengthy task unless you call QApplication::processEvents() and let the application to process it's events every now and then.

    It's a bit problematic when the lengthy task isn't written by you. You cannot get QApplication::processEvents() called (nor a progress dialog advanced) during for example like in your situation, just a single library call. One option is to move the code calling that library function to another thread. But unfortunately in your situation it might be impossible since you really shouldn't touch widgets in another than the main GUI thread.

    I have come to a conclusion that you don't have many options here. Maybe you could just inform the user about what's going to happen: "Saving the image. Please be patient." :)

    Btw, have you tried setting useContext as TRUE when calling QGLWidget::renderPixmap()? I'm not sure about it's risks, but it promises to be more efficient.. :)
    J-P Nurmi

  6. #6
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qprogressDialog

    but the dialog must be called beofe or after renderPixmap(); this doesn't change the thing, I guess....that's incredibile....thanks
    Regards

Similar Threads

  1. setLabel in QprogressDialog
    By mickey in forum Newbie
    Replies: 5
    Last Post: 12th July 2006, 11:19

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.