[gelöst] Nur Tray-Icon: App beendet nach QMessageBox
Verfasst: 15. September 2009 17:07
Hallo,
ich habe einen QDialog und erstelle ein Tray-Icon mit QSystemTrayIcon. Da ich das Dialog-Fenster erst mal nicht brauche, habe ich in der main.cpp w.show(); auskommentiert:
Funktioniert wunderbar, nur wenn ich aus dem Tray (mit QMenu) eine QMessageBox ausgebe, beendet sich das komplette Programm danach einfach.
Lasse ich den Dialog ( w.show() ) anzeigen, gibts keine Problem. Die MessageBox wird dann auch nicht zentriert angezeigt, also habe ich über den Parent (this) nachgedacht und stattdessen "parent" verwendet. Die MsgBox ist jetzt zentriert, das Programm beendet aber danach immer noch.
Wieso beendet sich das Programm nach der MsgBox?
Gibts eine bessere Methode für ein "Nur-Tray-App"?
Danke
PS: Verwende den QTCreator.
ich habe einen QDialog und erstelle ein Tray-Icon mit QSystemTrayIcon. Da ich das Dialog-Fenster erst mal nicht brauche, habe ich in der main.cpp w.show(); auskommentiert:
Code: Alles auswählen
QApplication a(argc, argv);
Dialog w;
//w.show();
return a.exec();Code: Alles auswählen
statusAction = new QAction(tr("&Status"), this);
statusAction->setIcon(QIcon(":/dialog-information.png"));
connect(statusAction, SIGNAL(triggered()), this, SLOT(showStatus()));Code: Alles auswählen
void Dialog::showStatus()
{
msg("Windows will shut down after the following process ends:\nvlc.exe", "Status");
}Code: Alles auswählen
void Dialog::msg(QString text, QString title)
{
// Objekt wird im Konstruktor erstellt
// this->msgBox = new QMessageBox(this);
this->msgBox->setText(text);
this->msgBox->setWindowTitle(title);
this->msgBox->setIcon(QMessageBox::Information);
this->msgBox->exec();
}Wieso beendet sich das Programm nach der MsgBox?
Gibts eine bessere Methode für ein "Nur-Tray-App"?
Danke
PS: Verwende den QTCreator.