Re: scrollArea not updating
Did you apply layouts everywhere? Based on the fact that you use resize() and updateGeometry() I think not. And you should have.
Re: scrollArea not updating
I do have layouts everywhere.
I found a solution to my problem. I don't know if it's the best way, so if there's a better way please let me know. Also an explanation why it works would be helpful.
My solution was to add another line:
Code:
newProfile_->resize( newQWidgetWidth(), newQWidgetHeight() );
newProfile_->setMinimumSize( newQWidgetWidth(), newQWidgetHeight() );
newProfile_->updateGeometry();
and make sure all the tabs I want to display have their minimum size defined.
Re: scrollArea not updating
If you use resize() and updateGeometry then you are not using layouts everywhere...
Re: scrollArea not updating
Ok, I removed resize() and updateGeometry() and only left setMinimumSize() and it still works. So I guess I only need this one command.
Re: scrollArea not updating
What kind of widget is "newprofile_"? Is it a custom widget, a basic Qt widget or a complex widget composed of other widgets?
Re: scrollArea not updating
newprofile_ is a class that inherits Qwidget. It contains another QWidget X which has buttons and frames. The frames will eventually display a Qwt plot. Its parent is a QMainWindow.
Depending on user choice, I show/hide X. When X is hidden, another Qwidget Y is shown in its place. Y is also a class that inherits QWidget and I use the same parent (QMainWindow). An instance of Y is created inside newprofile_.
So the display can change between X and Y but both are on newprofile_ widget.
Actually, while trying to explain all that, I realised that maybe the parent of Y should be newprofile_ and not QMainWindow. I changed my code and now the layout works without setMinimumSize() and without me having to do anything special.
Thanks wysota. Sometimes it helps just trying to explain the things I do.
Re: scrollArea not updating
A side note - for switching between X and Y you could use QStackedWidget. It would improve your design a little (as I assume you are creating/showing/hiding those widgets yourself).
I'm digging the subject, because you were certainly missing a layout or a size hint here somewhere, but it's hard to say where without knowing the details.
Re: scrollArea not updating
I only create the widgets once (I have 13 of them) and let the user select from a QTreeWidget which one to show. I need to do it this way since each type of widget can appear multiple times but present different info depending on it's location in the tree and user input.
I had a look at QStackedWidget. It displays arrows (to move between the widgets), which probably was the reason I chose not to use it and I'm not sure if the size of the scroll area will adjust for different widget sizes if I put them all in the stacked widget or just always show the biggest size.
Other than that it does seem like a good idea. I think the way I wrote the code is very similar to QStackedWidget just using show/hide instead of signals. I have to finish other parts of the application first but I will make a note to come back to this one and see if it makes a difference.
I think my original problem stemmed from not having the right parent to all those new widgets. Once that was fixed everything worked well and I didn't have to set anything more.
Re: scrollArea not updating
Quote:
Originally Posted by
user
I had a look at QStackedWidget. It displays arrows (to move between the widgets), which probably was the reason I chose not to use it and I'm not sure if the size of the scroll area will adjust for different widget sizes if I put them all in the stacked widget or just always show the biggest size.
The arrows are only in Designer. They are not there in a real application.