PDA

View Full Version : Persistent combobox entries.



spsingh
10th March 2010, 10:15
I have a file browse button which displays a QFileDialog. On selecting a file I add the path to an editable combobox. What I want is a way to make all these entries persistent so that these are available in the combobox drop down the next time when the dialog is invoked? Does Qt have a preference framework for controls.

bmhautz
10th March 2010, 16:54
Take a look at QSettings: http://qt.nokia.com/doc/4.6/qsettings.html. You could iterate over the items in the combo box and add them to the application settings.

Edit: I forgot to add that you'll need to save it at the close of your application and then restore them when the application opens.

bmhautz
10th March 2010, 17:40
I forgot to add that if you just want this persistent over the life of the application and not between application sessions, then the easiest thing to do is to save the combo box information in a QList somewhere in your program and access it again when you instantiate the QComboBox widget.