Results 1 to 6 of 6

Thread: Dialog closes immediately

  1. #1
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question Dialog closes immediately

    Hello again,
    I've got a strange one going on now. I have two dialogs that I open. I do so with the .exec() to make them modal. When I close the first one, I open the second one with .exec(). It immediately returns. I stepped into the Qt code and found that it does this because at line #153 of qeventloop.cpp, the d->threadData->quitNow flag is set. If I skip over the next line (return -1 ), it comes up just fine and functions normally.

    I'm going to continue to search for what is going on, but if anyone has a clue, please let me know.

    Thanks for all the help
    - BRC

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog closes immediately

    Do you happen to open those dialogs in main()?

  3. #3
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Dialog closes immediately

    Quote Originally Posted by jacek View Post
    Do you happen to open those dialogs in main()?
    No - I've created a QObject based class with a slot that I call from main with QMetaObject::invokeMethod() call using Qt::QueuedConnection parameter. The first dialog comes up just fine (usually). But sometimes even the first dialog closes before I see it too. So, perhaps this is the problem. The support people at Qt told me to do it this way. Before I had all of the dialog calls in main().

    The main application goes on to the app.exec() call.

    - BRC

  4. #4
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Dialog closes immediately

    More information -
    I can't even reopen the first dialog. It appears that there is some global variable that is getting set when I close the first dialog that causes all other dialogs to want to close as well. It's almost like I've set the system to close the entire application.

    hmmmm - still researching.

    - BRC

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog closes immediately

    Quote Originally Posted by bruccutler View Post
    No - I've created a QObject based class with a slot that I call from main with QMetaObject::invokeMethod() call using Qt::QueuedConnection parameter. [...]
    The main application goes on to the app.exec() call.
    I see, but the solution is the is the same:

    Qt Code:
    1. int main( int argc, char **argv ) {
    2. QApplication app( argc, argv );
    3. app.setQuitOnLastWindowClosed( false );
    4. ...
    5. app.setQuitOnLastWindowClosed( true );
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    QApplication::setQuitOnLastWindowClosed()

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

    bruccutler (21st February 2007)

  7. #6
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Dialog closes immediately

    Quote Originally Posted by jacek View Post
    I see, but the solution is the is the same:

    Qt Code:
    1. int main( int argc, char **argv ) {
    2. QApplication app( argc, argv );
    3. app.setQuitOnLastWindowClosed( false );
    4. ...
    5. app.setQuitOnLastWindowClosed( true );
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    QApplication::setQuitOnLastWindowClosed()
    Thanks - I had just encountered that option and was going to see if it might be the issue. Thanks, I think this is what is happening.

    BRC

Similar Threads

  1. Replies: 1
    Last Post: 1st February 2007, 17:07
  2. Replies: 3
    Last Post: 23rd July 2006, 18:02
  3. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22
  4. Dialog positioning in GNOME
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 09:41
  5. QLineedit::returnPressed() closes dialog?
    By geranol in forum Newbie
    Replies: 2
    Last Post: 6th January 2006, 10:18

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.