PDA

View Full Version : QScrollArea behaves differently after I call hide() or show() on contained widget



frankiefrank
6th February 2011, 16:02
I have an application showing QwtPlot widgets inside a QScrollArea.

I have the following code defining my scrollable container:



holder = new QWidget(ui.groupBoxChart);

myVerticalLayout = new QVBoxLayout(holder);
ui.scrollArea->setWidgetResizable(true);
ui.scrollArea->setWidget(holder);


When the user checks a checkbox deciding which plot to display, this code is called:


MyPlot *newPlot = new MyPlot(ui.scrollArea);

myVerticalLayout->addWidget(newPlot);

newPlot->show();


When the user checks a different checkbox, the code hides any displayed plots with hide();

Currently the behavior I get is -
* the first time a plot is shown it is shrinked to fit the size of the scroll area *without* scrollbars displayed.
* after checking a different check box and then checking the first one again (causing hide and then show) the plot is redisplayed larger than the scroll area (thus causing the scrollbars to appear).

I would like to understand what causes this, and then decide how i want it to behave.

franz
7th February 2011, 15:54
Can you post a fully compiling example (preferably without the qwt requirement...)?

frankiefrank
8th February 2011, 18:07
Thanks for the reply. Will be a bit hard as I'm working around other issues. I hope I can manage to and then I will update the thread.