[Qt-interest] how to restore a saved scoll position
Zoltan Molnar
zoltan.molnar at lmsintl.com
Fri Feb 5 14:19:44 CET 2010
Hi all,
I would like to restore a view in the scrolled position it was before
exiting an application.
I currently use the following logic to save and load the actual scroll
pos:
Upon save I inquire the sliderPosition of both scrollbars:
void save(QGraphicsView* v)
{
QScrollBar *h_sb = v->horizontalScrollBar();
QScrollBar *v_sb = v->verticalScrollBar();
int aHorizVal = h_sb->sliderPosition();
int aVerticVal= v_sb->sliderPosition();
outstream << aHorizVal << aVerticVal;
}
Load is called after the scene has been populated already.
void load(QGraphicsView* v)
{
int h_val, v_val;
inpstream >> h_val; inpstream >> v_val;
QScrollBar *h_sb = v->horizontalScrollBar();
QScrollBar *v_sb = v->verticalScrollBar();
h_sb->setSliderPosition(h_val);
v_sb->setSliderPosition(v_val);
}
Can anybody recommend me a better way to do this? This seems to me a
little fragile.
Br, Zoltan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100205/52fe5e12/attachment.html
More information about the Qt-interest-old
mailing list