qsettings

QLocale and QSettings

╄→尐↘猪︶ㄣ 提交于 2019-12-08 03:56:28
问题 Premise: I'm on osx using qt5.7 I've changed the decimal separator in the System Preferences - Language and Region - Advanced to use the comma: I have a problem in storing/restoring the QLocale value via QSettings . This is the main.cpp : #include <QSettings> #include <QDebug> void printLocale(QString header, QLocale locale) { qDebug() << QLocale::languageToString(locale.language()) << QLocale::scriptToString(locale.script()) << QLocale::countryToString(locale.country()) << locale

Where does Qt/C++ Store System Scope QSettings on Mac OSX 10?

不羁岁月 提交于 2019-12-06 16:45:38
According to Qt's docs for the latest Qt version, looking at QSettings , they say that system scope of settings on a Mac are stored in a directory /etc/xdg. Unfortunately, I'm not finding this to be the case on Mac OSX 10.10 Yosemite. Where do they store these settings? I mean, I've gotten QSettings to work in this example , but no /etc/xdg folder is to be found even when I do sudo su and assume root on my Mac in order to access that folder. On a MacOS, $HOME/Library/Preferences/ should be the location for user settings, while /Library/Preferences/ is the path for default settings (and a user

Can i read from .ini file which located in resources files?

走远了吗. 提交于 2019-12-05 13:45:37
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QSettings> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSettings * qsettings = new QSettings(":/config.ini",QSettings::IniFormat); bool status = qsettings->value("preview","").toBool(); qDebug() << status; } MainWindow::~MainWindow() { delete ui; } Once i could do it but now i don't know whats wrong. When i googled this problem i just saw that this impossible but i enshure that i did it before. This works like a charm for me: main.qrc <!DOCTYPE RCC><RCC

QSettings - where is the location of the ini file?

对着背影说爱祢 提交于 2019-12-03 08:19:26
问题 I'm using QSettings to store some data as ini file in Windows. I want to see the ini file, but I don't know what is the location of the ini file. This is my code: QSettings *set = new QSettings(QSettings::IniFormat, QSettings::UserScope, "bbb", "aaa"); set->setValue("size", size()); set->setValue("pos", pos()); Where do I have to look? Or may be I miss the code which write it to the file? When does the QSettings write its values? 回答1: To print out the exact location of your settings file use

How to load settings in Qt app with QSettings

你说的曾经没有我的故事 提交于 2019-12-03 06:18:41
问题 There are two possible ways: load all settings into some struct load values on-demand Which approach is better? 回答1: It depends on the way you will use your settings file . Do you want to allow the user of your application to dynamically change the settings in the file (.ini file for example) ? Or the settings have to be set by the GUI ? If you are using some GUI to change the settings, I advice you you to load the main settings at the start of your application from a static class for example

QSettings - where is the location of the ini file?

倖福魔咒の 提交于 2019-12-02 23:39:06
I'm using QSettings to store some data as ini file in Windows. I want to see the ini file, but I don't know what is the location of the ini file. This is my code: QSettings *set = new QSettings(QSettings::IniFormat, QSettings::UserScope, "bbb", "aaa"); set->setValue("size", size()); set->setValue("pos", pos()); Where do I have to look? Or may be I miss the code which write it to the file? When does the QSettings write its values? To print out the exact location of your settings file use method fileName method of QSettings class. QSettings settings("folderName", "fileName"); qDebug() <<

How to load settings in Qt app with QSettings

牧云@^-^@ 提交于 2019-12-02 19:39:59
There are two possible ways: load all settings into some struct load values on-demand Which approach is better? It depends on the way you will use your settings file . Do you want to allow the user of your application to dynamically change the settings in the file (.ini file for example) ? Or the settings have to be set by the GUI ? If you are using some GUI to change the settings, I advice you you to load the main settings at the start of your application from a static class for example. void SettingsManager::loadSettings() { // .ini format example QSettings settings(FileName, QSettings:

QSettings doesn't handle unicode well

孤街醉人 提交于 2019-12-01 17:24:09
问题 I'm using QSettings to store some settings in an INI file. However, my program is not in English, so some of the settings contain Unicode strings. It seems that Qt writes INI files not in utf8 or utf16, but in some other encoding, the string "Привет мир!" (rus. "Hello world!") looks like this: WindowTitle=\x41f\x440\x438\x432\x435\x442 \x43c\x438\x440! I want to edit settings file by hand, but I can't quite work with it like this. Is there a way to force Qt to save in Unicode? 回答1: Check the

QSettings doesn't handle unicode well

眉间皱痕 提交于 2019-12-01 17:08:25
I'm using QSettings to store some settings in an INI file. However, my program is not in English, so some of the settings contain Unicode strings. It seems that Qt writes INI files not in utf8 or utf16, but in some other encoding, the string "Привет мир!" (rus. "Hello world!") looks like this: WindowTitle=\x41f\x440\x438\x432\x435\x442 \x43c\x438\x440! I want to edit settings file by hand, but I can't quite work with it like this. Is there a way to force Qt to save in Unicode? Check the setIniCodec function of QSettings Sets the codec for accessing INI files (including .conf files on Unix) to

How to save selected Items to Qsettings from QListWidget, QTableWidget

天涯浪子 提交于 2019-12-01 12:20:47
I am Using PyQt5 and Py3.7, I am trying to loop through all my Qlistwidgets and save their string data, but also save all selected items on that widget. I slightly modified the loop from here , but am having some trouble getting the selected items to save and restore using the listwidget array loop. I checked the docs but can't seem to understand how to add additional options into the array (such as save all selected items), from the Qt docs for SetArrayIndex, here . My listWidgets have selectionMode set to MultiSelection. I am currently saving using this: def save_list_data(self): self