QGridlayout problems
-
I am trying to use QGridLayout as a grid, where each widget is placed where i want, but this is not possible as each Widget goes where it wants. eg: doing ui->gridLayout->addWidget(remove,1,1,2,2); has no effects, as the widget streches to the entire layout. I only want to assign each widget a fixed position.
-
Are you sure you are using it correctly? Now you define that your widget should be at row 1 in cell 1. You also define columnSpan and rowSpan 2. It means that your widget takes two row cells and two columns cells of the layout.
Do you have any other widgets in the layout?
-
well, if you place only one widget, this looks allright.
See also:
[quote author="weggi" date="1305487017"]Are you sure you are using it correctly? Now you define that your widget should be at row 1 in cell 1. You also define columnSpan and rowSpan 2. It means that your widget takes two row cells and two columns cells of the layout.Do you have any other widgets in the layout?[/quote]
If you have somewhere in the QGridLayout already several widgets in a row than it should build a grid.
"Like in the example":http://doc.qt.nokia.com/4.7/qgridlayout.html -
If you want a fixed size single widget, you probably do not want a layout at all. For me it's still unclear, what you want to achieve.
The space of a toplevel widget is split between the subwidgets that are put in a layout. As your button is the only widget it gets all the available space. If you have more widgets, the space is split by several rules. You can make some of the subwidgets a fixed size, see the QWidget docs on size policy etc. for some infos.
Maybe you should play around with grid layout on a widget in Qt Designer to become comfortable with it's workings.
-
Not sure what you are trying to achieve, but you could also try 3x3 grid, button in the middle and "spacers":http://doc.qt.nokia.com/latest/qspaceritem.html#details around the button.
-
Perhaps reading the "introduction to layouts":http://doc.qt.nokia.com/4.7/layout.html could also give some insight.