[Qt-interest] how to restore a saved scoll position

Zoltan Molnar zoltan.molnar at lmsintl.com
Fri Feb 5 15:29:33 CET 2010


I am not concerned about read/write settings.  

Rather about restoring by:

 

v->horizontalScrollBar()->setSliderPosition(vvv);

 

I wonder if there is a nicer way to achieve this.

 

br, Zoli

 

 

________________________________

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Jefferson
Bandeira
Sent: Friday, February 05, 2010 4:06 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] how to restore a saved scoll position

 

You could try QSettings, is quite simples and good to use, check online
docs or QAssistant

2010/2/5 Zoltan Molnar <zoltan.molnar at lmsintl.com>

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

 


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
Jefferson Bandeira

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100205/f9718c1a/attachment.html 


More information about the Qt-interest-old mailing list