So I could do something like...
Qt Code:
{ // i have no idea what i should write here, maybe like... Qt::WindowStates flag = qwsc_event->oldState (); }To copy to clipboard, switch view to plain text mode
So I could do something like...
Qt Code:
{ // i have no idea what i should write here, maybe like... Qt::WindowStates flag = qwsc_event->oldState (); }To copy to clipboard, switch view to plain text mode
Should workQt Code:
{ { //Now check to see if the window is minimised if( isMinimised() ) //Do something here (show the icon in the systray ) } }To copy to clipboard, switch view to plain text mode
Edit:
don't do a dynamic cast at every event, instead check the event type
OK I will try it, but shouldn't I do something like forward the other events? How would I do that... like when an event is not a WindowStateChange how would I forward it for default processing? Should I do something like...
Qt Code:
{ { //Now check to see if the window is minimised if( isMinimised() ) { hide (); e->ignore (); } } else e->accept (); }To copy to clipboard, switch view to plain text mode
Sure.
It was just an on-the-fly example.
Of course you have to forward the other events.
Regards
Well actually the function returns a bool so I did this:
Qt Code:
{ { //Now check to see if the window is minimised if (isMinimized()) { e->accept (); hide (); } else e->ignore (); return true; } e->ignore (); return false; }To copy to clipboard, switch view to plain text mode
But this messes my application, like the widgets are not drawn and the QCloseEvent is not sent anymore. I also tried setting other combinations like ignoring the message instead of accepting it and returning false instead of true but that didn't either.
Would installEventFilter() work too? I'm looking in to it right now...
One should pass the events to the base class implementation. Also, it's recommended to reimplement more specialized QWidget::changeEvent() instead of QWidget::event().
Qt Code:
{ { //Now check to see if the window is minimised if (isMinimized()) { hide (); } } }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Yes, passing the ignored events to the base class will solve your problem.
That didn't help either
I also tried accepting and/or ignoring events and also didn't work, the window is still not hidden from the taskbar and the client area not painted.
]Qt Code:
{ { //Now check to see if the window is minimised if (isMinimized()) { hide (); } } }To copy to clipboard, switch view to plain text mode
Is this what you did?
EDIT: This is what you need to do. You have to let QDialog handle the change event. You must not accept nor ignore the event. Just hide your window.
regards
Last edited by marcel; 17th April 2007 at 08:21.
aLiNuSh (17th April 2007)
Maybe... I tried so many different combinations I can't remember anymore.
Anyways I tried it now and it does the same thing... when I push the minimize button the window minimizes to the taskbar and the taskbar "button for the window" disappears and appears again quickly, and then when I maximize it, the window shows on the screen but the client area is not painted. Obviously it has to be something with some of the events not being forwarded for default processing... i just don't know what I'm missing here...![]()
![]()
Could you show me the actual code? The one that you last tried![]()
I just closed Notepad++ and deleted the code... basically I've tried reimplementing changeEvent () or event () sometimes accepting or rejecting the events, sometimes returning true or false or QWidget::changeEvent ()/event() and other different combinations.
I lost 4 hours on this stupid thing and still haven't got it working.
Anyways thanks for the assistance and maybe when I'll feel masochist enough I'll retry it :P
We're from the same country BTW
LE: tried the edited one too.. same thing![]()
Last edited by aLiNuSh; 17th April 2007 at 09:13.
Hi !
I also have the problem with the systrayicon and minimize
so i try following ...
Qt Code:
// Overload original event-handler: { // Check if Window-State changed to minimize ... { //Now check to see if the window is minimised if (isMinimized()) { // Call the Hide Slot after 250ms // to prozess other events .... qApp->processEvents(); evt->ignore(); } } // Call original-handler (in this case QMainWindow ...) }To copy to clipboard, switch view to plain text mode
... this work's on windows !
Use the below code it might be helpful to you.......
Qt Code:
//System tray icon action context menu connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); //ToolbarAction(itemExit).icon(), ToolbarAction(itemExit).text(), parent); cmenu.addAction(tr("Show"), this, SLOT(show())); cmenu.addAction(tr("Hide"), this, SLOT(hide())); cmenu.addSeparator(); cmenu.addAction(minimizeAction); cmenu.addAction(maximizeAction); cmenu.addAction(restoreAction); cmenu.addAction(quitAction);To copy to clipboard, switch view to plain text mode
Hi, here is a solution, and I think it works quite well in my application:
In the dialog's slot that connects with the activated() signal of the QSystemTrayIcon object, use the setParent() function as:
Qt Code:
{ setParent(NULL, Qt::Window); showNormal(); sysTrayIcon->hide(); } }To copy to clipboard, switch view to plain text mode
And in the dialog's event() function:
Qt Code:
{ if (isMinimized()) { setParent(tmp, Qt::SubWindow); sysTrayIcon->show(); e->ignore(); qDebug()<<"event() called"; } else { e->accept(); } } }To copy to clipboard, switch view to plain text mode
Here, 'tmp' is an empty QWidget serving as a provisional 'parent' of the dialog, so that the dialog can be hidden from task-bar when minimized. In fact, you can just pass NULL as the first argument for the 'parent' widget, but in this case probably the re-stored window would exhibit slightly different with the original window size.
Bookmarks