Results 1 to 3 of 3

Thread: Why when I close QDialog my main application gets killed?

  1. #1
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Why when I close QDialog my main application gets killed?

    Hi,
    I have a dialog that is started from a context menu of my application. The problem is that when I close the dialog, my application closes as well. How do I make a dialog such that the main application stays running when the dialog is closed? (I open the dialog with a parent widget=0. MyDialog inherits QDialog. My main application is a tray icon on the panel with a context menu).

    Thanks a lot!
    Alex.

    Qt Code:
    1. MainApplication::MainApplication()
    2. {
    3. ...
    4. myDialog = 0;
    5. }
    6.  
    7. void MainApplication:: openDialog() {
    8. if (!myDialog)
    9. myDialog = new MyDialog;
    10.  
    11. myDialog->show();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 17th July 2008 at 21:45. Reason: missing [code] tags

  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: Why when I close QDialog my main application gets killed?

    Set QApplication::quitOnLastWindowClosed property to false.

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

    alex chpenst (10th July 2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why when I close QDialog my main application gets killed?

    works fine, thanks for quick help!!!
    alex.

Similar Threads

  1. Replies: 3
    Last Post: 31st March 2006, 18:38

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.