Search code examples
c++qtqlineedit

Saving values in QLineEdit


I have a couple QLineEdit widgets in my project. I enter something, call methods and close the window. Can I save values in QLineEdit widgets, so when I open an app, values which I entered were there? I only can set values by default using QLineEdit::setText, but I need more flexible way.


Solution

  • Can I save values in QLineEdit widgets, so when I open an app, values which I entered were there?

    Not particularly. Widgets don't implement this, you have to code that yourself. You can use a regular file for each QLineEdit to store the contents, or you can use QSettings class. Simply, you'll want to read the settings when the application starts and write when it exits.