Asperamanca
27th January 2011, 09:51
Hi,
I use a QGraphicsGridLayout to lay out some QGraphicsWidget items like this:
_layout->addItem(_anLegend,0,0);
_layout->addItem(_dateField,1,0);
_layout->addItem(_leftScale,0,1);
_layout->addItem(_anCurCanvas,0,2);
_layout->addItem(_rightScale,0,3);
_layout->addItem(_timeScale,1,2,1,1);
_layout->addItem(_diLegend,2,0,1,2);
_layout->addItem(_diCurCanvas,2,2,1,1);
When I comment the last two lines (thus not adding _diLegend and _diCurCanvas), the layout changes accordingly, and my remaining components get the extra space. Great.
However, when I add the items to the layout as shown, but later on hide them thus...
_diCurCanvas->setVisible(false);
_diLegend->setVisible(false);
_layout->invalidate();
_layout->activate();
...the items become invisible, but the layout does not hand out the extra space; I get the blank background at the position the items were.
What am I missing? Do I have to change the size policy of items as they become invisible? I though layouts consider and handle item (in)visibility?
I use a QGraphicsGridLayout to lay out some QGraphicsWidget items like this:
_layout->addItem(_anLegend,0,0);
_layout->addItem(_dateField,1,0);
_layout->addItem(_leftScale,0,1);
_layout->addItem(_anCurCanvas,0,2);
_layout->addItem(_rightScale,0,3);
_layout->addItem(_timeScale,1,2,1,1);
_layout->addItem(_diLegend,2,0,1,2);
_layout->addItem(_diCurCanvas,2,2,1,1);
When I comment the last two lines (thus not adding _diLegend and _diCurCanvas), the layout changes accordingly, and my remaining components get the extra space. Great.
However, when I add the items to the layout as shown, but later on hide them thus...
_diCurCanvas->setVisible(false);
_diLegend->setVisible(false);
_layout->invalidate();
_layout->activate();
...the items become invisible, but the layout does not hand out the extra space; I get the blank background at the position the items were.
What am I missing? Do I have to change the size policy of items as they become invisible? I though layouts consider and handle item (in)visibility?