Wenn ich anstatt dem MinimizeEvent auf das CloseEvent reagiere geht es, wenn ich mit close() den CloseEvent jedoch feuer (anstatt mit dem X-Button) klappt es ebenfalls nicht.
Hat jemand eine Ahnung wie ich einen QDialog komplett in den SystemTray
minimieren kann? (SystemTrayIcon ist vorhanden
hier mal wie ich es als letztes versucht hatte
Code: Alles auswählen
void testDialog::trayIconActivated(QSystemTrayIcon::ActivationReason reason){
if(reason == QSystemTrayIcon::Trigger){
this->sysIcon->hide();
this->setWindowFlags(Qt::Dialog | Qt::WindowMinimizeButtonHint); //<- alle alten WindowFlags wieder herstellen
this->show();
this->showNormal();
}
}
void testDialog::changeEvent(QEvent *event ){
if(event->type() == QEvent::WindowStateChange && this->windowState() == Qt::WindowMinimized){
this->minimizeToTray = true;
this->close();
}
}
void testDialog::closeEvent(QCloseEvent *event){
if(this->minimizeToTray){
this->sysIcon->show();
this->setWindowFlags(Qt::SubWindow); //<- das hatte mir gefehlt :)
event->ignore();
this->minimizeToTray = false;
} else {
this->sysIcon->hide();
}
}