QWidget resize not restoring window size
-
I copied these read & write routines from the QSettings doc
void Widget::write_settings ( void ) { QSettings settings ( "Daiajo" , "Combo" ) ; settings . beginGroup ( "Window" ) ; settings . setValue ( "Size" , size () ) ; settings . setValue ( "Position" , pos () ) ; QTextStream out ( stdout ) ; out << "Height = " << size () . height () << " Width = " << size () . width () << endl ; settings . endGroup () ; settings . setValue ( "Linux/Selection" , text_label -> text () ) ; } void Widget::read_settings ( void ) { QSettings settings ( "Daiajo" , "Combo" ) ; settings . beginGroup ( "Window" ) ; resize ( settings . value ( "Size" , QSize ( 400 , 400 ) ) . toSize () ) ; move ( settings . value ( "Position" , QPoint ( 200 , 200 ) ) . toPoint () ) ; QTextStream out ( stdout ) ; out << "Height = " << size () . height () << " Width = " << size () . width () << endl ; settings . endGroup () ; text_label -> setText ( settings . value ( "Linux/Selection" , "Gentoo" ) . toString () ) ; }
The Window/Position and Linux/Selection are being restored, but the Window/Size isn't. The output lines I put show that the new size of the window is being saved and restored, but the window on the screen is always 150,250; not the 200,200 default, not the saved value. Width wise the window fits the 2 widgets, but height wise its way too big. (Not sure how to get the window image in. Its just a comboBox and Label in a Hlayout.)
So what extra do I need to do to make the window return to whatever size they made it?
Also I can't find the settings file. I haven't specified any location information, so I was expecting ~/.config/Daiajo/Combo or something in the working directory. I also looked in /etc/xdg without finding anything.
-
@Daiajo
What type is your Widget class? Is it your main window?As stated in QSettings documentation:
"On Unix systems, if the file format is NativeFormat, the following files are used by default:
$HOME/.config/MySoft/Star Runner.conf (Qt for Embedded Linux: $HOME/Settings/MySoft/Star Runner.conf)
$HOME/.config/MySoft.conf (Qt for Embedded Linux: $HOME/Settings/MySoft.conf)
for each directory <dir> in $XDG_CONFIG_DIRS: <dir>/MySoft/Star Runner.conf
for each directory <dir> in $XDG_CONFIG_DIRS: <dir>/MySoft.conf
" -