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
3
votes
2 answers

How to add/change registry in qt?

I tried QSettings mSettings; mSettings.setValue("HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/USBTOR/Start", 4); This didn't work.
Vinay Kulkarni
  • 81
  • 1
  • 10
3
votes
1 answer

What's the standard approach for configuration in Qt console apps?

In .Net you typically have an app.config file and built in ways to access the configuration. Is there an equivalent standard approach to configuration using Qt? For example, lets say my application connects to an online server, I want the ability…
JL.
  • 78,954
  • 126
  • 311
  • 459
3
votes
3 answers

Saving 64-bit integer with QSettings

Is there any neat way, short of converting number to QByteArray, to save quint64 with QSettings? The problem is QVariant doesn't accept qint64 nor quint64.
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
3
votes
1 answer

Some queries on QSettings, qmlRegisterType() and setContextProperty

I will try explaining my confusion through the application I am currently developing. My application (based on Qt5.1 + Qt Quick Controls) interacts with Facebook API to manage a Facebook Page. I am trying to keep the QML code (for UI) as separate…
bhootjb
  • 1,501
  • 1
  • 21
  • 33
3
votes
1 answer

QSettings adds percent symbol to the group name

I have QSettings object in ini format. When I write settings.beginGroup("GENERAL") in the ini file i see the following: [%General] Why does this happen?
Funt
  • 399
  • 8
  • 23
3
votes
0 answers

How to use mixed mode .net assembly in Qt 4.8.4 application?

In my Qt application I use .net assembly wrapped in COM which uses Microsoft.DirectX library. When I launch my application it crashes with the following details in output