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
0
votes
1 answer

Event when value in QSettings changes?

I am not sure how exactly to project settings changes immediatelly onto my application. One way would be to listen on some QEvent using eventFilter. Is that an option? Is there any such event? If listening on event is bad idea, what's the correct…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
0
votes
1 answer

QSettings rewriting the .ini file, so not able to restore the values

When I am using below code on Linux SLES 11 machine the .ini file is recreating for some reason so that I am not able to restore my settings. Same code working fine on Windows machine. Prb: I want to have recently opened file list on start up…
NDestiny
  • 1,133
  • 1
  • 12
  • 28
0
votes
0 answers

Including QSettings file in Static QT Release

Is it possible to add a QSettings fileto a static Qt Release? How can I accomplish this, specifically (add as a resource, add something to .pro file, etc.) Currently my application makes the QSettings file if one does not exist (which it does not on…
Rachael
  • 1,965
  • 4
  • 29
  • 55
0
votes
2 answers

fontComboBox QSettings application unexpectedly quits

I am trying to implement QSettings in an editor of mine. I am trying to implement it for font changes. However, whenever I start up my program it exits immediately. Here's my code: When I change the font in my font box. void…
crank123
  • 251
  • 1
  • 4
  • 17
0
votes
1 answer

QSettings how to read ini without value of keys

I have config: [Users] joe bill dona serg I need QStringList with all usernames. QSettings ini("/tmp/users.ini", QSettings::NativeFormat); ini.beginGroup("Users"); QStringList keys = ini.allKeys(); qDebug() << keys; ini.endGroup(); This not work…
Šerg
  • 793
  • 5
  • 18
0
votes
2 answers

Saving combination of QSpinBox and QComboBox using QSettings

Now, this is a one which is baffling me, Giving a short example of my sample GUI, i. I have four labels in the mainwindow, label_1, label_2, label_3, label_4 ii. I have a spinBox, comboBox and a pushButton as well. iii. The values in comboBox are…
RicoRicochet
  • 2,249
  • 9
  • 28
  • 53
0
votes
0 answers

Qt Qsettings .INI only works in RUN mode and NOT in applicatin mode (.app)

I use a .ini file to save QSettings when the application is shut down. //store url in QSettings QSettings* settings = new QSettings("my_config_file.ini", QSettings::IniFormat); settings->setValue("url", str); settings->sync(); I use the default…
KarelV
  • 1
0
votes
0 answers

QSettings registry and redirect on regedit 64bit (Wow6432)

I'm developing an application using the Qt framework. One of the features is to get all registry from HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall using QSettings. When I was testing, I found something curious: My code get the path…
Eric
  • 75
  • 2
  • 14
0
votes
0 answers

Restore maximized/normal window after launching minimized app in QT

I have a problem with my Qt app. I can save and restore qeometry of my app without any problem. The problem is when I try to saveGeometry of maximized app in close event and after that I try to start the some app minimized (something like "Run…
0
votes
1 answer

iterate over settings dictionary with Qsettings with boolean values

Hm, I thought I was clever to manage my PyQt settings with a (Python) dictionary. That way I thought I could iterate over the settings at least for saving and comparing. But I got problems when using boolean values. I have a method def…
uli_1973
  • 705
  • 1
  • 5
  • 22
0
votes
1 answer

Read array of custom metatype from QSettings

I have a problem with reading custom metatype data from QSetting. I have a class: class MusicOwner { public: MusicOwner() : songs_count(0), id(0) {} explicit MusicOwner(const Song &owner_radio); Song toOwnerRadio()…
shed
  • 121
  • 1
  • 8
0
votes
1 answer

QSetting for a QList

I have a QList of some non-primitive data type, say QList tmp; I want to store this whole list into settings, for writing and reloading, so that i don't lose my settings on restart. I tried settings.setValue("reference", tmp); but…
shivshnkr
  • 1,435
  • 1
  • 13
  • 19
0
votes
2 answers

How might I use QSettings to load different setups

I have a Qt application that requires the ability to load from several settings files to behave in a distinct way. For example lets say my app can support several variations, VAR1, VAR2, VAR3, ... One of my menu entries allows me to load settings.…
pklemm
  • 1
  • 3
0
votes
3 answers

Qt: Pass variables from ClassA to ClassB via Class C

I have the following layout: MainWindow <--------- Settings \ \ V PerformOps MainWindow takes in variables passed from Settings, and passes them on to PerformOps. If the Settings class is not used, MainWindow passed on defaults…
tetris11
  • 817
  • 2
  • 11
  • 27
0
votes
1 answer

how change textcolor editor in qt

this is my syntax editor program i want to show keyword,classes,function and ...with Separate color i set the color in config file(with Qsetting) for example this in my config file : FunctionColor=blue an in my cod i read the the…
1 2 3
12
13