Results 1 to 2 of 2

Thread: Problem with closing the application

  1. #1
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Problem with closing the application

    Hello, I have a very odd problem.
    During the start-up of my application, I do some checks to see whether the plugins were loaded properly, etc. All these checks happen in the constructor of the MainWindow (descendant of QMainWindow) and when some of them fails, I want to close the application. However, using QApplication::close(), close(), qApp->quit() or destroy() has no effect (or, at least it does not close the application, I am not aware of any other side-effects), the MainWindow shows up (and later my application crashes because it assumes the plugins are already loaded).

    My closeEvent() is reimplemented,
    Qt Code:
    1. void MainWindow::closeEvent(QCloseEvent *event){
    2. workspace->closeAllWindows();
    3. if (activeWindow()) {
    4. event->ignore();
    5. } else {
    6. event->accept();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 
    but I think that the problem is elswhere, because I checked that the event->accept() line is called.

    Do you have any ideas how to close the application?

    Thanks...

  2. #2
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with closing the application

    You might want to move the checks outside of the constructor & call them before your exec() (or show() or whatever). If you move the checks to a "bool MainWindow::checkPlugins()" call, you can then check the return value and either bring up the main window or exit the application.

    Vycke

Similar Threads

  1. application freezes without crashing (and closing)
    By nass in forum Qt Programming
    Replies: 15
    Last Post: 25th September 2007, 11:21
  2. Replies: 7
    Last Post: 28th June 2007, 17:18
  3. Replies: 5
    Last Post: 15th June 2007, 22:08
  4. Application deployment problem
    By shapirlex in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th April 2007, 00:11
  5. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49

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.