Did you apply a top level layout? Unselect child widgets, open up context menu over the background of the form and select a layout. See this thread for a screenshot: http://www.qtcentre.org/forum/f-qt-d...lved-9897.html
Did you apply a top level layout? Unselect child widgets, open up context menu over the background of the form and select a layout. See this thread for a screenshot: http://www.qtcentre.org/forum/f-qt-d...lved-9897.html
J-P Nurmi
Hi,
Sorry, I didn't said that I have a QGridLayout (all the code is handwritten). And I don't do it with Designer because the number of columns and rows of windows(like OpenGL widgets) can be modified.Did you apply a top level layout?
Thanks for replies, but it works using
as you told me.Qt Code:
To copy to clipboard, switch view to plain text mode
Next time I will try to try using size policies.
Thanks,
Òscar Llarch i Galán
Well, if you insist doing it wrong, I suggest you at least take a look at Window Geometry documentation. There is no need to query window's title height when placing its child widgets. You just have to choose proper methods which exclude window frame.
J-P Nurmi
Hi,
Well, or I don't explain it well or you don't understood me.
Do you really think that I'm doing it wrong? Wich is the good way? I'm not able to make sizePolicies work well (expanded and maximum don't expand the centreal widget to avaiable space).
Thanks,
Òscar Llarch i Galán
If you set a widget using QMainWindow::setCentralWidget, the main window will handle resizing the widget to fit the window contents. If it doesn't happen, it means that the widget you set for the central widget doesn't have a layout applied. If you apply the layout, it will work out of the box. Consider the following code:
Qt Code:
int main(int argc, char **argv){ QMainWindow mw; for(int i=0;i<5;i++){ // te->setGeometry(0, i*40, 200, 35); // % l->addWidget(te); // * } mw.setCentralWidget(w); mw.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Try it and then comment out lines that are marked with asterisks and remove the comment from the line marked with the percent sign and try again, you'll see the difference while resizing.
Unfortunately, yes I do. A good way is to rely on layouts and not to manually position children upon resize event. If you ever decide for example to change language or font, manually resized children will fail miserably. Layouts will take care of not only resize event but also a lot of other situations when geometries need to be managed.
It's not about size policies it the layout management doesn't work at all. Size policies and stretch factors are ways to fine tune after you get layout managers properly installed and working. Either you didn't set the central widget with QMainWindow::setCentralWidget() or the central widget itself has no layout installed.I'm not able to make sizePolicies work well (expanded and maximum don't expand the centreal widget to avaiable space).
J-P Nurmi
Hi,
mmm...
I have a centralWidget that have a QGridLayout manager.
You know that when you resize Docks, remove or insert ToolBars, ... the space that centralWidget has is changed. Ok, so I only want that the centralWidget size is the corresponding size, not to ScrollBars apear.
Think that I have 4 OpenGL widgets and I want that have to be full visible, so them have to be resized when Docks are resized.
Thanks,
Òscar Llarch i Galán
It's all doable using size policies. Child widgets should have the policy set to Maximum or Preferred and it should work. Check out the code I gave you - the text edits adjust their size according to the size of the main window's central widget. You may only get scroll bars if you use a scroll area - get rid of it and the problem might go away.
Hi,
Thanks, this was the problem. I removed the ScrollArea and now the centralWidget is resized to the maximum avaiable space.You may only get scroll bars if you use a scroll area
Thanks,
Òscar Llarch i Galán
It would probably also worked if you had called setWidgetResizable(true) on the scroll area.
^NyAw^ (13th November 2007)
Bookmarks