Results 1 to 4 of 4

Thread: What is meant by Local Event loop in Modal Dialog Context?

  1. #1
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Exclamation What is meant by Local Event loop in Modal Dialog Context?

    Qt doc says:
    void QDialog::done ( int r ) [virtual slot]

    Closes the dialog and sets its result code to r. If this dialog is shown with exec(), done() causes the local event loop to finish, and exec() to return r.
    myDialog.exec();

    inside myDialog slots..

    {
    ///////
    done(1);//here the Dialog invisible
    QProgressDialog dia;
    ////dialog related parameters
    foreach(---){
    //update progress ba
    qApp->processEvents();
    //////
    }

    }
    what is the behavior of processEvents() after done() and before done() with above QProgressbar?how events are handled in both the cases?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is meant by Local Event loop in Modal Dialog Context?

    That doesn't look like something you would want to have in any pprogram of yours.

    Calling done but keeping operating the dialog is not a good idea. If the dialog is allocated on the stack it will be deleted while this code still executes.

    If you want to hide the dialog call hide() and call done() when you are done.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: What is meant by Local Event loop in Modal Dialog Context?

    what is the behavior of processEvents() after done() and before done() with above QProgressbar?
    A long-running for loop blocks the normal Qt event loop so painting and user interaction cannot function. The processEvents() inside the for loop ensures that the GUI is responsive and able to update while the for loop executes. In this particular scenario it would not be necessary if you are calling setValue() to update the progress bar: it calls processEvents() internally.

    There is no processEvents() before done() is called in your snippet.

    Consider processing the results from the modal dialog in the location that called exec() not inside the dialog class.

  4. #4
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: What is meant by Local Event loop in Modal Dialog Context?

    I wanted to know the behaviour of processEvents() before done(),as the local event loop is alive. So what is the behaviour if done() is called, but codes executing with procesEvents().Thanks in advance.

    Quote Originally Posted by ChrisW67 View Post
    A long-running for loop blocks the normal Qt event loop so painting and user interaction cannot function. The processEvents() inside the for loop ensures that the GUI is responsive and able to update while the for loop executes. In this particular scenario it would not be necessary if you are calling setValue() to update the progress bar: it calls processEvents() internally.

    There is no processEvents() before done() is called in your snippet.

    Consider processing the results from the modal dialog in the location that called exec() not inside the dialog class.

Similar Threads

  1. Replies: 4
    Last Post: 6th August 2011, 01:40
  2. Non-Modal about dialog?
    By N3wb in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2010, 05:47
  3. Replies: 1
    Last Post: 21st June 2010, 07:26
  4. Replies: 10
    Last Post: 15th January 2010, 14:35
  5. Modal dialog in QMainWindow's event() function
    By tanminh in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2007, 09:46

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.