Solved How do I make a scrollbar move along with the hosting widget?
-
Hi,
I have a widget/window that hosts 2 scroll bars (vertical and horizontal). I want them to remain sticking to the bottom and right-hand-side of my window when I resize it but that does not happen - their position is fixed which means they either disappear or "remain behind" when I resize it. Now there is an example offered by QCustomPlot ("scrollbar-axis-range-control") that does exactly what I want using some creator/designer settings I assume - maybe layout - but I just don't seem to grasp how to do it!
Can someone please help me?
Thanks in advance. -
Hi
Did you use layouts to glue it all together ? -
Hi,
Out of curiosity, why not use QScrollArea ?
-
Hi,
Thanks for the suggestion. Sounds good !
@mrjj I fiddled with some options there with no satisfying result (then I went to bed).
I will mark this solved if a QScrollArea satisfies my needs.
Thanks for both. -
Folks,
Even QScollArea behaves the exact same way - the scroll bars do not follow the temporal window's dimensions. Any idea? Alternatives?
I have noticed that the QCustomPlot widget itself does not change in size (I gave up QScrollArea) - it must be the same issue? Is it layout related? -
@tamirmichael
Well it normally does.
Did you apply a layout to the viewport of the scoll area ? -
Can you show maybe some picture/sketch of what you are trying to achieved ?
Did you make QScrollArea the hosting widget ?
-
-
How are you setting that up ?
-
Does it matter which layout type?
I will try to mess with QScollArea somewhat more...how do I set it to "host" ? Tried to drop the scroll bar onto it etc. without result...@SGaist So far I only added the scroll area, and tried to place the scrollbars where I want them, on or off it - with negative results.
I see that dragging the QScrollArea does indeed change the location of my scroll bar too - does that mean that its "hosting"? I see no change in behavior though...
Can you tell me in a few short sentences what I need to do? It's silly I have a working example but I cannot seem to find anything at all about it that makes it work! :-( -
@tamirmichael
Hi
I checked the sample and its now clear what you mean.
You want to scroll the axes of the customplot with the scrollbars.
adn not scroll the actual widget around.
You need all the code from the example to do so. (except setupPlot())
private slots:
void horzScrollBarChanged(int value);
void vertScrollBarChanged(int value);
void xAxisChanged(QCPRange range);
void yAxisChanged(QCPRange range);
and their code.
and the connect statements and othe code from constructor.the example uses a QGridLayout to keep scrollbars following the customplot.
You can still use a ScrollArea if you want instead of the free scrollbars. -
Hopeless UI design ! Hopeless !
-
@tamirmichael
why is it hopeless ?
Its fully documented and works pretty nice.
https://doc.qt.io/qt-5/layout.html -
I think it is tremendously un-intuitive. There other ways to suggest that behavior like this is to be induced, and the link above does indeed demonstrates that I am not the only one who just did not get it. Either way thanks.