QScrollArea with mixed content, how to scroll that no labels or QLineedits will be cut off?`
i am currently working on a embedded solution which has a LCD attached + keypad.
I have a Widget where the IP settings can be configured.
The Widget has a QScrollArea which contains a Gridlayout with several Labels and regarding QLineEdits.
The problem is now, if I move the focus (using keyboard) down or up, the labels and QLineEdits can be cut off at the beginning or the end of the scrollarea.
I know this is normal windows behaviour, but how can I achieve it that the labels and the regarding QLineEdit will be always fully viewable without having them cut off?
So target solution shall be if I scroll up/down the elements which are shown in the ScrollArea shall not be cut off.
Is there some generic solution or idea how to achieve it?
I already tried using offset and redrawing, but this will be a lot of effort for the widgets, so I am searching for a more generic and smarter solution.
Many Thanks in advance
Have you tried
on the widget you wish to be fully visible?
Thank you for your reply, I tried:
ui->scrollArea->ensureWidgetVisible( ui->label );
but the label is still cut off, do I am using it wrong?
The label which shall not be cut off is insige a gridlayout of the scrollarea.
Well I used it on a widget that hold the other elements.
I added some y margin before i liked it fully.
You must call it when you navigate. Like on keypress. then call it.
Since I think you have more than one label,
ensureWidgetVisible( ui->label );
You can use event filter to catch changing focus
You cant just call it once.
Ahh okay I see, but this will not prevent the cut off of the other elements, but I am thinking if I go this way how to ensure that the previous label is also be shown?
is in the scrollara and the ensure is set to the button, how to make sure that the label before is also fully visible in combiantion with the button a line below?
There the buttons are still cut off. It would be nice if the elements are always fully displayed and scrolled elementwise.
The scrollarea height is fixed, so no resize possible on the target.
Any idea for this issue?
well you can maybe adjust scroll amount
so it matches the height you want.
so each scroll would scroll one "row" height being
what ever u want.
So the last one is never cut.
Settings the scrollheight would fit if the height is always the same.
But how to get it Händler more dynammically if for example one "row" has a different height?
I am really thinking about a generic solution for multiple pages/Widgets.
So any help is appreciated also thanks for currently answers.
Some further thougt s ;) how to get this done for different "row" heights?
Does anyone have a further solution or hint, how this could be achieved?
I cannot imagine this was never done with Qt ;).
You can try to use ensureWidgetVisible by calling it if e.g. the scroll bar has not been moved for a certain amount of time.
Hope it helps