[Kde-java] QSettings.sync( )

Richard Dale Richard_Dale at tipitina.demon.co.uk
Wed Oct 6 13:58:40 CEST 2004


On Wednesday 06 October 2004 12:21, David Goodenough wrote:
> I presume that QSettings.sync is there to make sure that when saving
> settings that the data is actually written out, given that there are no
> real reliable destructors in Java.  I presume also that it should be used
> in preference to dispose?
I would assume the settings are written out when the app exits. In KDE there's 
a KMainWindow.queryClose() method where that gets done.

> Are there other classes like QSettings which normally assume a
> reliable destructor mechanism and for which extra explict actions
> on the programmers behalf are required?
I don't think it's normally a problem.

> I am also confused by the loadsettings( ) routine shown in the Qt
> Designer manual.  It runs like this:-
>
> private void loadSettings( ) {
>  QSettings settings = new QSettings( );
>  int windowWidth = settings.readNumEntry( APP_KEY + "WindowWidth", 550);
>  int windowHeight = settings.readNumEntry( APP_KEY + "WindowHeight", 500);
>  int windowX = settings.readNumEntry( APP_KEY + "WindowX", 0);
>  int windowY = settings.readNumEntry( APP_KEY + "WindowY", 0);
>  m_clip_as = settings.readNumEntry( APP_KEY + "ClipAs", CLIP_AS_HEX);
>  m_show_web = settings.readBoolEntry( APP_KEY + "ShowWeb");
>  if( !settings.readBoolEntry( "View", true))
>   {
>    colourWidgetStack.raiseWidget( iconsPage);
>    viewIconsAction.setOn( true);
>    }
>  }
>
> The thing that confused me is that the window* variables are read,
> but never used.  Is there something in the C++ environment that
> makes this implicit, or is the manual just wrong.  For my Java
> version I had to add explicit calls to resize and move for the window
> to return to where it was saved.
Yes, I think you would need that in C++ too.

-- Richard


More information about the Kde-java mailing list