All,

I have been fighting with this for soem time, and I'd thought i'd ask.

I have an app that has a QComboBox that holds the last 5 ipaddresses used. I want to save the contents of this with Qsettings to INI file and read them back in.

I have a readSettings and a saveSettings that creates the INI file, but only writes the current entry in the file, not all the past ones.

I have looked in the docs but it only shows how to use setValue and Value on QLineEdit, not QComboBox.

Any ideas or sample code you can point me to?

Here are the read and save functions, but the Combo box bits are removed. I coulnd not even get close to a workable solution for it..

Qt Code:
  1. void Porcupine::readSettings()
  2. {
  3.  
  4. QSettings settings(QSettings::IniFormat, QSettings::UserScope,"software", "app1");
  5.  
  6. settings.beginGroup("MainWindow");
  7. resize(settings.value("size", QSize(800, 400)).toSize());
  8. move(settings.value("pos", QPoint(200, 200)).toPoint());
  9. settings.endGroup();
  10.  
  11. settings.beginGroup("network");
  12. // The connection details go here
  13. settings.endGroup();
  14.  
  15. ui.statusLogs->append(tr("Settings Restored"));
  16.  
  17.  
  18. }
  19.  
  20. // Saves in (linux) $home/.config/software/app1.ini
  21.  
  22. void Porcupine::saveSettings()
  23. {
  24.  
  25. QSettings settings(QSettings::IniFormat, QSettings::UserScope,"software", "app1");
  26.  
  27. settings.beginGroup("MainWindow");
  28. settings.setValue("size", size());
  29. settings.setValue("pos", pos());
  30. settings.endGroup();
  31.  
  32. settings.beginGroup("network");
  33. settings.setValue("ipaddress", ui.ipaddressComboBox->currentText());
  34. settings.setValue("printerPortNumber", ui.printerPortNumber->text());
  35. settings.endGroup();
  36.  
  37. ui.statusLogs->append(tr("Settings Saved"));
  38.  
  39. }
To copy to clipboard, switch view to plain text mode 

Thanks for all the help.

Chris