PDA

View Full Version : Maximize a widget (to fill its parent



Ohman
10th October 2008, 14:05
hi,

I have a QglWidget which I would like to be 100% of the size of his parent QMainWindow.

When I create the QglWidget he is the right size (parent auto-created), but now I tried to maximize it with :


QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(QSizePolicy::Expand ing);
sizePolicy.setVerticalPolicy(QSizePolicy::Expandin g);
qglWidget.setSizePolicy(sizePolicy);

but it doesn't seem to work

Any idea ?

bob_the_badger
10th October 2008, 14:23
What if you stick it in a layout and then add a stretch factor greater than 1?

maverick_pol
10th October 2008, 14:37
Hi,

1. Set layout for the window and add the widget to the layout with enabled max stretch.
2. When maximizing the main window set widget geometry to fill the whole window.(brutal force)
3. Make sure you do not have any "bar" objects (toolbar,etc) which will not allow the widget to make the whole available space.

Kacper

aamer4yu
10th October 2008, 15:52
Try setting the margins ans spacing in layout to zero.
Else if you want to show some widget maximised, you can use QWidget::showMaximized()

elcuco
11th October 2008, 13:15
Similar question to this one:

I saw in a few web pages, a flash movie that contains a button that when you press it, the movie goes out of the original frame, and fits the whole window (not full screen!)

I would like to implement this in a QWidget:
I want to yank a QWidget from a layout, and then force it to be take the whole content of the window. Has anyone done such thing and can give me some hints about how can I do this?

Ohman
13th October 2008, 12:10
hello guys,

it was a layout problem indeed, but I resolved it just by using setCentralWidget instead of addWidget