Lazy loading in QScrollArea
I have been trying to implement lazy loading in QScrollarea. Widget are being added (say 20 Qlabel) at bottom and same number of widgets are being deleted from top.
Problem is, scrollbar or scrolling is happening automatically not in normal fashion way.
As soon as i delete item from top, all bottom item move up and scrolling gets disturbed.
Can anybody help with situation.?
I assume you are using a layout on the scroll area which means
that the layout will adjust when you delete widgets.
You can try to disable the layout before you remove the top ones and
enable again when ready.
I tried doing it, but effect is weird
after doing this layout autoscrolling stops,but futher scrolling all item get remove something weird happens
ok, i have not tried such setup with scrollarea
so not sure what "something weird happens" covers.
Using a listview with delegate is not an option?
- add a custom QWidget into the scroll area
- in this custom widget set a fixed size (setFixedSize()) of the sizeHint() from the layout
- when you now add a widget the scrolling doesn't "jump"
- now repeat step (2) after scrolling is done and the scrollbar can be adapted
try the following:
ui->scrollArea->blockSignals(true); updateScrollAreaPage(); ui->scrollArea->blockSignals(false);
howerver, ita untested from my side
my guess is that this doesn't change anything, since there happens so much more (event-driven) in the background than signals from the scrollarea
@raven-worx you're mostlikly right, x) didn't think it through enough, I guess.
Had a long morning...