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
Code:
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
MainWindow w;
//w.show();
return a.exec();
}
Method, displaying the About dialog
Code:
void MainWindow::aboutDialog()
{
QMessageBox::about(this, trUtf8
("Title"), trUtf8
("Some text"));
}
EDIT:
Solved the problem by setting QuitOnLastWindowClosed property to false. Sorry for bothering you :o
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.
Code:
QMessageBox::about(this,tr
("TitleGoesHere"), tr
("This program is about dialog info here"));
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.