Results 1 to 3 of 3

Thread: close() and deleteLater()

  1. #1
    Join Date
    Aug 2013
    Posts
    25
    Thanks
    7
    Qt products
    Qt5

    Default close() and deleteLater()

    Hi,

    I have created an application which has several UI forms. When the user clicks on the shutdown button, the ui form for shutdown appears where i call a function to save the last state of the application to a database. On completion I emit a signal. This signal is connected to a slot where I have written this->close();

    When I run my application I see using qDebug() << messages that the slot where this->close(); is written is executed but it does not close the UI application.

    I wrote this->deleteLater(); instead and it successfully closed the application.

    Is this a correct way to do it? Any help is appreciated.

    Giselle

  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: close() and deleteLater()

    Is any of the other windows still open when you call close()?

    In any case there is nothing wrong with deleting the window at program end.

    Cheers,
    _

  3. #3
    Join Date
    Aug 2013
    Posts
    25
    Thanks
    7
    Qt products
    Qt5

    Default Re: close() and deleteLater()

    Hi,

    Thank you for your reply.

    There is no other window open. If I add a pushbutton and implement this->close(); in the onclicked slot of pushbutton the window closes.

    But if I were to simply call a function and that saves the application last state and at the end emits a signal stating all states saved and if i connect this signal to a slot which implements this->close(); it does not close. Only this->deleteLater(); works in this case. Anycase if deleting the window at the end of the program is Ok then I will use this->deleteLater();


    Thank you

Similar Threads

  1. deleteLater?
    By ggdev001 in forum Qt Programming
    Replies: 9
    Last Post: 4th March 2013, 20:58
  2. To use or not to use: deleteLater()
    By codeslicer in forum Qt Programming
    Replies: 11
    Last Post: 11th July 2009, 21:43
  3. QT deleteLater again.
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2008, 22:36
  4. Qt Deletelater
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2008, 16:58
  5. QObject::deleteLater
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2007, 16:25

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.