Hi,

When the user starts my application for the first time, I load some default settings. Then, upon exiting, I save the user settings which I reload the next time round.

Now, I was wondering what is the best way to do this in a Qt application. I currently save the user settings by overriding closeEvent(). The idea is that the GUI is still visible at that stage which allows me to properly save the user settings.

I am, however, facing problems with the loading of the user settings, especially with those related to a QTreeView-based widget. Basically, I have some kind of a file browser within my application and the first time the user starts my application, I would like my QTreeView-based widget to have its columns resized to their contents, but then allow the user to resize them manually if s/he so desires (and save that information in the user settings). At the same time, I want to keep track of the folder/file that is currently selected and, the next time, the user starts my application have my QTreeView-based widget point to that folder/file.

My understanding is that in order to do this, I would need my QTreeView-based widget to be visible. This means that I clearly can't do that in the constructor of my GUI class, or even QTreeView-based widget class. I therefore thought that I could do something similar to overriding closeEvent(), i.e. override showEvent() and have a static boolean that would be used to handle the loading of the user settings. Unfortunately, that approach doesn't work with my QTreeView-based widget. I just can't get the headers to autoresize or the folder/file to be scrolled to properly. In fact, this is not quite true, I have got things to work by displaying a dialog box just before doing to the autoresizing or scrolling, and it was fine, but I clearly don't want to have to display a dialog box to get things to work. So, it seems to me that my problem is that the GUI takes some time to become visible which means that I can't properly load the user settings.

So... what is the 'best' strategy to load/save user settings that require the GUI to be fully visible? I wish there was some kind of startEvent() method (i.e. the exact opposite of closeEvent()) which I could override...

Cheers, Alan.