[solved] QScrollArea on Tab with QGridLayout not working
-
Here are captures of before using only QGridLayout and after using the QScrollArea. !http://i59.tinypic.com/bj5w9j.jpg(QGridLayout Only - No Servos Added)!!http://i58.tinypic.com/287nsxi.jpg(QGridLayout Only - Servos Added)!!http://i62.tinypic.com/2zjkh78.jpg(QScrollArea Used - No Servos Added)!!http://i60.tinypic.com/fdcbvs.jpg(QScrollArea Used - Servos Added)!
-
And without that line ?
@pScrollArea->setWidgetResizable(true);@
-
I tried it both with and without "setWidgetResizable." No scroll bars. No change in behavior. Horizontal size is fixed, adding things squishes the other columns. Without the ScrollArea the right side would grow. I was wondering over the weekend, can you do something so that all tabs on a TabWidget have scroll areas or do you have to do each tab individually?
Thanks. -
I got the behavior I wanted by setting the central widget of my mainwindow to the QScrollArea and setting "setWidgetResizable" to true. I then added my tabwidget (subclassed as SF_UnitView) to the ScrollArea. This enabled the ScrollArea on all the tabs. So far this seems to work the way I was hoping.
My only other issues now is that on the initial tab I have a picture. It maintains its aspect ratio if the window is smaller than the picture but will stretch the picture horizontally but not vertically when the window is sized bigger than its minimum size. Do I need to intercept the resize and adjust it so the aspect is right? Thanks for all your suggestions.
-
Your widgets were nested differently than I thought, but anyway, cool you found a solution.
Do you mean resize when it's smaller otherwise keep it size ?
-
Actually, resize when the window is larger than the picture so the picture keeps its aspect ratio. When the window is larger than the picture, the picture will stretch horizontally but not vertically causing it to lose its aspect ratio. I don't know much about catching the resize signal at this point but I am guessing I need to adjust the vertical to match the horizontal stretch? Not a huge issue now but would make it look nicer in the end. Thanks,
-
How did you setup that picture ?
-
This is the code for the label. Its placed in an HBox with a spacer on the right side.
@ pLabelSF_Logo = new QLabel;
pLabelSF_Logo->setMinimumWidth(600);
pLabelSF_Logo->setMinimumHeight(232);
pLabelSF_Logo->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
pLabelSF_Logo->setScaledContents(true);
pLabelSF_Logo->setPixmap(QPixmap("../SFPackage/Smart-Fly_Logo3.jpg"));
@ -
Then you should rather create your own e.g QFrame and draw the image yourself so you can scale it as wanted
-
You're welcome !
If your primary problem is solved then please update the thread title prepending [solved] so other forum users may know as solution has been found :)