Results 1 to 8 of 8

Thread: QProgressDialog locks process until dismissed

  1. #1
    Join Date
    Mar 2012
    Location
    Glasgow, Scotland.
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QProgressDialog locks process until dismissed

    I'm trying to implement a QProgressDialog as a "busy" prompt to give the user some feedback that something is happening while a function executes but my code shows the QProgressDialog & doesn't continue processing the rest of the code unless I close the QProgressDialog using the close button.

    Qt Code:
    1. QWinWidget win( launchParams.hWndParent );
    2.  
    3. QProgressDialog progress ("Initializing Model Viewer II\nPlease wait...", QString(), 0, 0);
    4. progress.setWindowModality(Qt::WindowModal);
    5. progress.exec();
    6.  
    7. gModelViewer = new VE2Modelviewer ( launchParams.flags, QString::fromAscii(launchParams.veXMLPath), &win );
    8. if( gModelViewer->LoadModel( launchParams.veXMLPath ) )
    9. {
    10. gModelViewer->show();
    11. progress.hide();
    To copy to clipboard, switch view to plain text mode 

    this just sits with the progressbar in the QProgressDialog looping endlessly. gModelViewer will never be shown without user interaction dismissing the QProgressDialog.

    Any help would be most appreciated.

  2. #2
    Join Date
    Mar 2012
    Location
    Glasgow, Scotland.
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProgressDialog locks process until dismissed

    Changing the code to the following makes it work as intended but the progress bar doesn't animate.


    Qt Code:
    1. QProgressDialog progress("Initializing Model Viewer II\nPlease wait...", QString(), 0, 0);
    2. progress.show();
    3. qApp->processEvents();
    4. try
    5. {
    6. QWinWidget win( launchParams.hWndParent );
    7. gModelViewer = new VE2Modelviewer ( launchParams.flags, QString::fromAscii(launchParams.veXMLPath), &win );
    8. if( gModelViewer->LoadModel( launchParams.veXMLPath ) )
    9. {
    10. gModelViewer->show();
    11. progress.hide();
    To copy to clipboard, switch view to plain text mode 

    Getting the progress bar to animate would be the only remaining step.

    Again any help is most appreciated.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QProgressDialog locks process until dismissed

    Why should it animate? you gave it min and max both 0 any you are not setting any new values as the progress goes on.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Mar 2012
    Location
    Glasgow, Scotland.
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProgressDialog locks process until dismissed

    Quote Originally Posted by high_flyer View Post
    Why should it animate? you gave it min and max both 0 any you are not setting any new values as the progress goes on.
    http://qt-project.org/doc/qt-4.8/qpr...r.html#details

    If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QProgressDialog locks process until dismissed

    I see.
    I thought your wanted to animate the progress as it goes on...

    I just tried it on a test project and it works perfectly. Windows 7, MSVC8, Qt8.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Mar 2012
    Location
    Glasgow, Scotland.
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProgressDialog locks process until dismissed

    I suspect us mixing MFC & Qt is where the problem lies then.

  7. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: QProgressDialog locks process until dismissed

    Please read this article

  8. #8
    Join Date
    Mar 2012
    Location
    Tver, Russia
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    1
    Thanked 3 Times in 1 Post

    Default Re: QProgressDialog locks process until dismissed

    As I remember, you may also set -1 to progress bar

Similar Threads

  1. QwtPlotZoomer locks up, possibly bug?
    By Neekeetos in forum Qwt
    Replies: 12
    Last Post: 10th February 2012, 13:49
  2. Replies: 2
    Last Post: 28th December 2010, 07:20
  3. QFile locks debug environment in QThread
    By nickolais in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 08:20
  4. QSqlDatabase, threaded access and locks
    By neuron in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2009, 16:55
  5. QThread locks my gui ??
    By LordQt in forum Qt Programming
    Replies: 8
    Last Post: 8th December 2008, 20: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
  •  
Qt is a trademark of The Qt Company.