
Originally Posted by
ComaWhite
Here is what I have to do it for me
void
if (Settings::enableSystemTray()) {
if (Settings::minimizeToTrayOnClose()) {
hide();
event->ignore();
}
} else {
KXmlGuiWindow::closeEvent(event);
}
}
void
MainWindow::closeEvent(QCloseEvent *event) {
if (Settings::enableSystemTray()) {
if (Settings::minimizeToTrayOnClose()) {
hide();
event->ignore();
}
} else {
KXmlGuiWindow::closeEvent(event);
}
}
To copy to clipboard, switch view to plain text mode
Just replace KXmlGuiWindow with QMainWindow since KXmlGuiWindow is KDE code
I just tried this and it doesn't work. Maybe you misunderstood what I am trying to do. I don't think I was clear enough
here is some code:
int main(int argc, char *argv[])
{
// create and show main window
TestWindow* mainWindow = new TestWindow();
mainWindow->show();
// create and show child window
childWindow->show();
/// now we have 2 windows on screen and 1 icon on taskbar
// hide main window.
mainWindow->hide() ;
// now I have childWindow on screen but no icons on taskbar.
// I would like to the taskbar icon to remain and its functions (maximize, minimize, close, etc) to control the child window.
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// create and show main window
TestWindow* mainWindow = new TestWindow();
mainWindow->show();
// create and show child window
QMainWindow* childWindow = new QMainWindow(mainWindow);
childWindow->show();
/// now we have 2 windows on screen and 1 icon on taskbar
// hide main window.
mainWindow->hide() ;
// now I have childWindow on screen but no icons on taskbar.
// I would like to the taskbar icon to remain and its functions (maximize, minimize, close, etc) to control the child window.
return a.exec();
}
To copy to clipboard, switch view to plain text mode
In my TestWindow class i overrode the closeEvent as you had it and It didn't work for me. In fact, the closeEvent isnt fired after a hide()
Bookmarks