PDA

View Full Version : QMdiArea: Maximaized SubWindow in background?



JohnnyRep
23rd March 2012, 10:34
Hi everyone!

I am using a QMdiArea with a couple of QGLWidget-subwindows. I would like to have one of the GLWidgets to fill the whole background of the QMdiArea, so that all other subwindows are always in front of it. As its background objects QMdiArea expects a QBrush-Objects, so there's no chance to set a normal widget as background I suppose?!

Now I was wondering if I could place a maximized subwindow in the background, having the other subwindows always on top of it. Is that possible? (I would need the maximized window to catch mouse+keyboard events)

Or is there a better/nicer solution for my problem?!

Many thanks!

J.R

wysota
23rd March 2012, 11:15
Use QAbstractScrollArea::setViewport() to set a custom widget as the viewport of the mdi area.

JohnnyRep
23rd March 2012, 17:41
Ah perfect! Thanks wysota!
It seems to work fine when I used a QTreeWidget (just for testing), but the QGLWidget gets reduced to 50x100pixel.
I would have thought that the viewport-widget always takes the maximum space available (= the full QMdiArea). setMinimumSize() etc. did not work!
Do you know, if I have to set a QSize somewhere to resize the GLWidget?

wysota
23rd March 2012, 17:51
The viewport occupies the whole visible area of the scroll area (apart the scrollbars). Maybe it's not the GL widget that is so small but rather you don't initialize the projection matrix of the GL widget properly?

JohnnyRep
23rd March 2012, 18:19
I must have done something wrong. When I am using the QGLWidget as a QMdiArea Subwindows it works fine (it always has the full size of the subwindow and I can resize and maximize it).
By adding a QMenu to my QGLWidget and set it as viewport it seems that just the QMenu is drawn. Is there any difference between a widget used in a subwindow and one used as a viewport? For me it looks like the QGLWidget does not take its space by the default when it is set as a viewport, when I am using a different Widget, such as the QTableWidget it'll take as much space as needed.