Hi.
I want my main window to hide on mimization event.
Googling around gave me this ideas:
First approach:
protected:
virtual void changeEvent
(QEvent*);
protected:
virtual void changeEvent(QEvent*);
To copy to clipboard, switch view to plain text mode
void LineWatcherMain
::changeEvent(QEvent* evt
){ if(evt
->type
()==QEvent::WindowStateChange&&isMinimized
()){ evt->ignore();
hide();
}
}
void LineWatcherMain::changeEvent(QEvent* evt){
if(evt->type()==QEvent::WindowStateChange&&isMinimized()){
evt->ignore();
hide();
}
}
To copy to clipboard, switch view to plain text mode
Second approach:
Same declaration as above, but different implementation.
void LineWatcherMain
::changeEvent(QEvent* evt
){ if(evt
->type
()==QEvent::WindowStateChange&&isMinimized
()){ evt->ignore();
hide();
}
void LineWatcherMain::changeEvent(QEvent* evt){
if(evt->type()==QEvent::WindowStateChange&&isMinimized()){
evt->ignore();
hide();
}else QMainWindow::changeEvent(evt);
}
To copy to clipboard, switch view to plain text mode
Third approach:
protected:
protected:
virtual bool eventFilter(QObject*,QEvent*);
To copy to clipboard, switch view to plain text mode
In constructor:
installEventFilter(this);
installEventFilter(this);
To copy to clipboard, switch view to plain text mode
Implementation:
if(evt
->type
()==QEvent::WindowStateChange&&isMinimized
()){ evt->ignore();
hide();
return true;
}
bool LineWatcherMain::eventFilter(QObject* obj,QEvent* evt){
if(evt->type()==QEvent::WindowStateChange&&isMinimized()){
evt->ignore();
hide();
return true;
}else return QMainWindow::eventFilter(obj,evt);
}
To copy to clipboard, switch view to plain text mode
All of them got 1 bug: window hide()'s, but when I'm doing show() it is mimized and even
if it was maximized it appears as normal.
What am I doing from?
Thank you.
Bookmarks