Results 1 to 2 of 2

Thread: QMessageBox::about() closes the application

  1. #1
    Join Date
    Nov 2009
    Location
    Lithuania
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMessageBox::about() closes the application

    Hi,

    I am developing an application which doesn't have top level window. Only a system tray icon. When I choose the about action in the system tray menu, it displays the About dialog and after I click Ok, the application quits. If the top level window is displayed, the About dialog doesn't terminate the application. I am using Qt 4.5.3 and Ubuntu 9.10

    main.cpp
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. //w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Method, displaying the About dialog
    Qt Code:
    1. void MainWindow::aboutDialog()
    2. {
    3. QMessageBox::about(this, trUtf8("Title"), trUtf8("Some text"));
    4. }
    To copy to clipboard, switch view to plain text mode 

    EDIT:
    Solved the problem by setting QuitOnLastWindowClosed property to false. Sorry for bothering you
    Last edited by M.; 15th November 2009 at 15:02. Reason: updated contents

  2. #2
    Join Date
    Nov 2009
    Location
    Southern California
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: QMessageBox::about() closes the application

    Just to help a little,
    QMessageBox has a special value for about dialogs.

    Basically it pulls the main program icon for the Icon to display within a normal dialog (instead of the warning/critical/question/etc) and sets up a basic dialog to add text & what not.

    Qt Code:
    1. QMessageBox::about(this,tr("TitleGoesHere"), tr("This program is about dialog info here"));
    To copy to clipboard, switch view to plain text mode 

    More info here: http://doc.trolltech.com/4.5/qmessagebox.html#about

    I just recently used it and I thought I could save you some trouble, or at least tidy up your existing program.

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. Replies: 1
    Last Post: 8th November 2009, 12:49
  3. QMessageBox closes entire application
    By Leoha_Zveri in forum Qt Programming
    Replies: 2
    Last Post: 19th September 2009, 11:44
  4. Deploying Qt 4.5.1 Application on RHEL 5.. Pls Help
    By swamyonline in forum Installation and Deployment
    Replies: 0
    Last Post: 28th June 2009, 11:43
  5. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37

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.