Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: how to close application

  1. #21
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to close application

    another way it is to do like this
    Qt Code:
    1. void Widget ::read_ncssettings()
    2. {
    3. QFile file("ncssettingss.ini");
    4. if(file.open(QFile::ReadOnly))
    5. {
    6. QMessageBox::information(this, "OK !", "file found, yeppie");
    7. QTextStream ts(&file);
    8. this->portno=ts.readLine(100);
    9. portno=portno.trimmed();
    10. this->baudrate=ts.readLine(100);
    11. baudrate=baudrate.trimmed();
    12. this->fmsname=ts.readLine(100);
    13. fmsname=fmsname.trimmed();
    14. qDebug() << baudrate;
    15. file.close();
    16. }
    17. else //if file is not found then give msg box and close the app
    18. {
    19. QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);//important line
    20. }
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 
    btw, in this case you don't need to use setQuitOnLastWindowClosed at all.
    so, the main should look like.
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. Widget w;
    5. w.show();
    6. return a.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  2. The following user says thank you to spirit for this useful post:

    mohanakrishnan (10th November 2009)

  3. #22
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    66
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to close application

    hi
    sorry i am using windows xp and winrar now i have attached them as seperate files
    pls look at them sorry for the inconvenience.
    thanks
    mohan
    Attached Files Attached Files

  4. #23
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    66
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to close application

    hi yogesh/spirit
    thanks a lot at last it worked as per ur idea i included the
    below line
    QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);//important line

    yes it clicked
    thanks a lot... for ur helps

  5. #24
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    66
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to close application

    hi spirit
    thanks for ur great help
    as u said i modified
    QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);//important line

    it works fine now ,
    thanks.....

Similar Threads

  1. About QMessageBox close my tray application
    By Doles in forum Qt Programming
    Replies: 2
    Last Post: 19th July 2008, 21:27
  2. Replies: 11
    Last Post: 15th July 2008, 13:11
  3. Why when I close QDialog my main application gets killed?
    By alex chpenst in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 22:57
  4. Close Event for DialogBased Application.
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2007, 12:33
  5. How to close application?
    By beerkg in forum Qt Programming
    Replies: 5
    Last Post: 10th August 2006, 19:26

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.