Results 1 to 6 of 6

Thread: Problem with QProgressDialog

  1. #1
    Join Date
    Nov 2010
    Location
    Cienfuegos, Cuba
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with QProgressDialog

    I'm using a QProgressDialog with the limits (0, 0) to show something during a sqlite query and preparing the results to show. The QProgressDialog window stays in blank all the time, not matter if the process took 1 second or minute. My code is something like:



    Qt Code:
    1. QProgressDialog dialog(this);
    2. dialog.setLabelText("Updating");
    3. dialog.setMinimun(0)
    4. dialog.setMaximum(0);
    5. dialog.show();
    6. try
    7. {
    8. // here I call a function that executes a sql query to a sqlite database and then updates the whole interface with the result.
    9. dialog.accept();
    10. }
    11. catch (QString e)
    12. {
    13. QMessageBox::critical(this, "Error - " + qApp->applicationName(), e);
    14. qApp->exit(1);
    15. }
    To copy to clipboard, switch view to plain text mode 

    Reading other post I have seen that in cases of a long during process is better to use another thread instead of the main one. It's this correct? Can I block the program during the process so the user can't interact with it when using another thread?

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

    Default Re: Problem with QProgressDialog

    Sql query blocks your application so that the progress bar doesn't have a chance to update itself. You can experiment with executing the query in a thread.
    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.


  3. #3
    Join Date
    May 2011
    Posts
    240
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Problem with QProgressDialog

    As far as I understand, at least the title should appear before going into the blocking part.

    Perhaps the UI operations are cached and need some extra help. I have sometimes added a xxxxx.update() after a xxxxx.show() to make a widget visible.

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

    Default Re: Problem with QProgressDialog

    Quote Originally Posted by mvuori View Post
    As far as I understand, at least the title should appear before going into the blocking part.
    No. For the window to appear, events need to be processed.
    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.


  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,478
    Thanked 274 Times in 269 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QProgressDialog

    Quote Originally Posted by mvuori View Post
    As far as I understand, at least the title should appear before going into the blocking part.

    Perhaps the UI operations are cached and need some extra help. I have sometimes added a xxxxx.update() after a xxxxx.show() to make a widget visible.
    After widget show add QCoreApplication::processEvents. But the best solution is to move SQL operations to another thread.

  6. The following user says thank you to Lesiok for this useful post:

    anoraxis (12th May 2011)

  7. #6
    Join Date
    Nov 2010
    Location
    Cienfuegos, Cuba
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QProgressDialog

    Ok, thanks. I will the sql part to another thread.

    Another thing, in my case the title of the QProgressDialog is the only element that appears, the rest of the dialog is blank.

Similar Threads

  1. Problem with QProgressDialog
    By anoraxis in forum Newbie
    Replies: 1
    Last Post: 6th April 2011, 22:23
  2. Problem with modal QProgressDialog
    By esterbonmati in forum Qt Programming
    Replies: 1
    Last Post: 15th January 2009, 11:59
  3. Need help in QProgressDialog
    By santhoshv84 in forum Qt Programming
    Replies: 3
    Last Post: 12th September 2008, 18:24
  4. QProgressDialog
    By samirg in forum Qt Programming
    Replies: 5
    Last Post: 5th September 2007, 16:37
  5. qprogressDialog
    By mickey in forum Qt Programming
    Replies: 5
    Last Post: 17th July 2006, 14:16

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.