December
31st July 2007, 16:20
Hi All,
I have tried everything I can find in this forum and on the web to get this to work, and nothing seems to solve my problem.
I have a program made with QT 4.3, which should hide to the tray icon.
When I hide it using the tray icon, it works fine, even on Windows the task-bar entry goes away, leaving just the icon tray:
void vfalerter::iconClicked( QSystemTrayIcon::ActivationReason reason )
{
if( reason == QSystemTrayIcon::Trigger ) {
// The icon in the tray was clicked
if(this->isVisible())
this->hide();
else
this->showNormal();
}
else if( reason == QSystemTrayIcon::MiddleClick ) {
// The icon was middle-clicked
showPopup( statusText, 1 );
}
}
That part works great. But when i try and capture the Minimize event from the main window, it leaves the task bar entry there.
bool vfalerter::eventFilter(QObject *obj, QEvent *event)
{
if( event->type() == QEvent::Hide ) {
// Window was minimized
this->hide();
return false;
}
else if( event->type() == QEvent::Close) {
// We are exiting
trayicon->hide();
// Delete any popups
while( popups.count() )
delPopup( popups[0] );
return false;
}
else if( event->type() == QEvent::Show) {
this->show();
return false;
}
else {
// Other events should be passed back to the main window
return QObject::eventFilter(obj, event);
}
}
The only way I have been able to make the taskbar entry go away in Windows from the minimize button is by adding:
setWindowFlags( Qt::SubWindow );
..to the hide function, but then the window never comes back the way it was when I restore it, and I'm pretty sure that wouldn't be the right way of doing it.
The whole things works as expected in KDE, its just Windows that has a problem.
Anyone got any ideas?
I have tried everything I can find in this forum and on the web to get this to work, and nothing seems to solve my problem.
I have a program made with QT 4.3, which should hide to the tray icon.
When I hide it using the tray icon, it works fine, even on Windows the task-bar entry goes away, leaving just the icon tray:
void vfalerter::iconClicked( QSystemTrayIcon::ActivationReason reason )
{
if( reason == QSystemTrayIcon::Trigger ) {
// The icon in the tray was clicked
if(this->isVisible())
this->hide();
else
this->showNormal();
}
else if( reason == QSystemTrayIcon::MiddleClick ) {
// The icon was middle-clicked
showPopup( statusText, 1 );
}
}
That part works great. But when i try and capture the Minimize event from the main window, it leaves the task bar entry there.
bool vfalerter::eventFilter(QObject *obj, QEvent *event)
{
if( event->type() == QEvent::Hide ) {
// Window was minimized
this->hide();
return false;
}
else if( event->type() == QEvent::Close) {
// We are exiting
trayicon->hide();
// Delete any popups
while( popups.count() )
delPopup( popups[0] );
return false;
}
else if( event->type() == QEvent::Show) {
this->show();
return false;
}
else {
// Other events should be passed back to the main window
return QObject::eventFilter(obj, event);
}
}
The only way I have been able to make the taskbar entry go away in Windows from the minimize button is by adding:
setWindowFlags( Qt::SubWindow );
..to the hide function, but then the window never comes back the way it was when I restore it, and I'm pretty sure that wouldn't be the right way of doing it.
The whole things works as expected in KDE, its just Windows that has a problem.
Anyone got any ideas?