PDA

View Full Version : Unable to handle WindowStateChange events



TheRonin
6th March 2008, 09:32
Hi there!

I'm sitting on linux and find myself needing to keep the user from changing the window state of a dialog. To start off with, i tried setting the window flags such that no minimize or maximize buttons would be shown. This failed since for some reason, my window manager insists on drawing at least a maximize button and depending on my system settings, a 'shade' button as well.

My next stop was to accept the minimize or maximize buttons being shown, but ignore the WindowStateChange events. So i implemented QDialog::changeEvent(QEvent*) in hopes of being able to ignore the appropriate events as they come in:



void MyDialog::changeEvent(QEvent* event)
{
if (event->type() == QEvent::WindowStateChange){
cout << "window state change event! window state:" << windowState() << endl;
//should i perhaps do event->accept() or event->ignore() here?
}else{
QDialog::changeEvent(event);
}

}

Unfortunately, this doesn't work either. The events are still getting through and the window is still being minimized and maximized. Am i completely at the mercy of the window manager or is there some way, any way, of solving this problem!?

thanks in advance!

wysota
6th March 2008, 11:20
You can tell the dialog to remain fixed in size, for instance using QLayout::sizeConstraint property.