Questions tagged [qsettings]

QSettings is a Qt class that provides an ability to store and use platform-independant settings for an application.

QSettings provides a very easy way to store, read and modify application settings in . Using this class is very simple.

The first thing to be done is creating an instance of QSettings. It gets 2 arguments which are the application's name, and the developer's company or organization. These are needed to name the settings files (on Unix-like systems) or the register branches (on Windows):

QSettings mySettings("myCompany","myAppName"); 

It is also possible to pre-set those values to get rid of the necessity of passing them every time a QSettings object is created. This can be done with QCoreApplication::setOrganizationName() and QCoreApplication::setApplicationName().

After a QSettings object is created, reading and writing settings is as easy as this:

//setting a value. The name should be QString, and the value can be a QVariant. 
mySettings.setValue("valueName", "value");
//reading a value:
mySettings.value("vaueName");

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

183 questions
-1
votes
1 answer

QSettings of ini file from internet

Im using this function so far: bool MSSQL::checkSettings() { QString settingsFile = "someDir/setup.ini"; QString fileName(settingsFile); QFile file(fileName); if(QFileInfo::exists(fileName)) { return true; } else { …
Jiri Zaloudek
  • 326
  • 3
  • 19
-1
votes
2 answers

C++ - QSettings question

Does Qt has something like QSettings, but for local scopes? I am seeking for a data structure with the same methods, but not specific for APPLICATION. I mean, I want to construct local (for example, exporting settings) settings from file (xml, for…
Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148
-2
votes
1 answer

Example For using QSettings to save QLineEdit text

Can I get a line of code that saves text of QLineedit and on restarting the app , it is retrieved ? Please help , its very important for my project …
rajatgupta431
  • 121
  • 1
  • 2
  • 10
1 2 3
12
13