PDA

View Full Version : making widget back from fullscreen



anoar
21st September 2009, 16:17
Hi all, I have following problem.

I have a widget (inherited QGraphicsView) that is somewhere inside central widget (in a groupbox with layout).
I want to have a possibility showing it fullscreen and then back it to normal.

Following code works great for going full screen:

void QGraphicsInheritedClass::goFullScreen()
{
this->setWindowFlags(Qt::Window);
this->setWindowState(Qt::WindowFullScreen);
this->show();
}

but using following code for going back:

void QGraphicsInheritedClass::goNormal()
{
this->setWindowState(Qt::WindowNoState);
this->setWindowFlags(Qt::Widget);
this->show();
}

destroys old geometries of parent widget (GroupBox is making bigger).
I tried calling updateGeometry() but this doesnt solve that.
Any idea how to solve that?

edit: this is somehow related to zooming. When I dont zoom groupbox keeps it size.

edit2: seems following code fixed my problem:

void QGraphicsInheritedClass::goNormal()
{
this->setWindowState(Qt::WindowNoState);
this->setWindowFlags(Qt::Widget);
QGraphicsScene scene;
QGraphicsScene * old = this->scene();
this->setScene(&scene);
this->show();
this->setScene(old);
}

any better idea?

kwisp
22nd September 2009, 07:14
why not
showNormal
showFullScreen
?

anoar
22nd September 2009, 17:13
because this widget was not a window