PDA

View Full Version : Resize qglwidget



Cucus
25th July 2011, 21:56
Hi,

I have a qWidget with a qglwidget an other form elements inside. How can I resize my qglwidget when i expand or reduce the qWidget?

Thanks

Talei
26th July 2011, 02:37
Add qglWidget to the layout and then add layout to the qWidget.

Cucus
26th July 2011, 21:27
An how I add the qglwidget to the layout?

Talei
27th July 2011, 16:51
Something along these lines:

QVBoxLayout *l = new QVBoxLayout();
l->addWidget( qglWidget );
this->setLayout( l );
And also RTM!

Cucus
28th July 2011, 14:29
In this case, all the qwidget is surrounded by the qglwidget, all my buttons are seen in black.

Talei
28th July 2011, 16:06
If you don't add buttons to the layout that's what will happen (if I understand Your correctly).

Cucus
28th July 2011, 16:26
I wish to add buttons to the layout:



QVBoxLayout *l = new QVBoxLayout();
l->addWidget(ui->GLpanel);
l->addLayout(ui->buttonInterface); //buttonInterface is a layout
this->setLayout(l);


However, if I do this, I have a segmentation fault calling l->addLayout(...)

Talei
28th July 2011, 16:58
I see you're using designer, so for simplicity sake do this:
1. place Your buttons and other widgets with designer
2. place EMPTY layout (whatever type) into place that You want to have qglWidget (You can place inside this layout temporary QWidget for easier visualisation, because empty layout is 0 pix width/height - depending on others layouts)
3. remove temporary QWidget and remember layout that this widget is in
at this point logical structure is like this (layout's are nested):
mainLayout (with all buttons + layout for glWidget)->glWidgetLayout (layout where you will place your glWidget)
then in your constructor, after UI initialization simply use:

ui->glWidgetLayout ->addWidget( glWidget );
Also see this (http://blog.lugru.com/2009/03/qtdesigner-and-qglwidget/) article. There is ready project that You can examine, because You error is in lacking of knowledge about layouts (everything what You ask is in manual RTM)