PDA

View Full Version : QGridLayout size not the same the second time



rperezalejo
26th September 2011, 03:27
hello community, i have a QGridLayout who i fill with some custom widget.

1- the first time i fill it i ask the hight and the answer is the right one, and is shown as i specked with these function, no problem at all.


this->yearLayout->getGrid()->sizeHint().height();

2- then i erase the content of the gridlayout these way:



while(this->pictureLayout->count() > 0)
{
QWidget* widget = this->pictureLayout->itemAt(0)->widget();
this->pictureLayout->removeWidget( widget );
delete widget;
}


3-if i fill again the grid with the same function of step 1 and ask the hight the answer is always "18" but the grid is shown as i specked with all the widget on every cell.
4- Never again i get the right hight value, just the first time i fill my grid.

i don´t know if is something these cleaning function do or if it set the grid to do something i don´t want. These way is cleaned perfect but i can´t ever get the height no more, and is what i want.

if any one can help me i will appreciate it.

hugs

sakya
26th September 2011, 12:22
Try to set the sizeConstraint to the layout you are removing and adding items:

this->pictureLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);

rperezalejo
27th September 2011, 02:19
I have tried all "::Set*" and no different results.

If i comment the grid cleaning function i get the result that i want but widgets are puts one over others, so the conclusion is that the not desire behavior is produce in these function.

And if i uncommented the result is the same:

1- first time (empty greed) it fill and hight is right (over 600)
2- second time after cleaning function (to clean first time widgets) the grid is fill properly but hight is not right (only 18 and must be at least the same as the fist time)
3- and so on

so the conclusion is that something is wrong with my cleaning function

wysota
27th September 2011, 02:55
Please provide a minimal compilable example reproducing the problem.