Save settings in UI
I'm a complete newbie (a noob) to QT Creator (1 week) so I'm sorry if this question is really dumb.
I'm a visual kind of person so being able to generate a UI with QT Creator has been a joyful experience but I seem to be missing something very fundamental and cannot seem to Google an answer.
I have all these lineEdits and checkBoxes designed as settings for the application in a popup QDialog with tabs. I can easily generate default values in Creator, which is what I want to begin with (first run) but then I want to run the app and change settings and have those settings stick.
At present, if I enter text in a lineEdit, uncheck or check a checkbox, radio button etc. in the running app nothing is saved. When I pop the window open again everything has reverted to the defaults.
Of course I understand I need to program something into the slots for the standard buttonBox with Cancel and Save. I see that the slot options for buttonBox is accept and reject. What do I need in the accepted slot to accept changes and override all the default values in the ui? ...and is that the way to do it or should it be generating a separate config text file.
Sorry if this has been answered before but I just can't find anything.
Hi, please take a look at "QSettings":http://qt-project.org/doc/qt-5/QSettings.html class. It can be used to remember values between application runs. If you want to remember them at runtime only (and/ or you do not want to use QSettings for some reason), then the solution is not to delete the dialog when it is accepted, only to hide it. The next time it's shown, it will still hold the same values.
I will give QSettings a go. Seems simple enough.