Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Is it possible to read file from resources files with QSettings?
MainWindow::MainWindow(QWidget *parent) :
QSettings * qsettings = new QSettings(":/config",QSettings::IniFormat);
QString status = qsettings->value("General/preview","").toString();
qDebug() << status;
QResource::registerResource("res.rcc"); QSettings settings1(":/config.ini"); QString sColor1 = settings1.value("preview").toString(); //File has "success=red", sColor reads to "red" QResource::unregisterResource("res.rcc");
qDebug() << sColor1;
If there no way so what i can use in qt for read file from resources and then parse it by keys like in QSettings?
Hi and welcome to devnet,
Might be a silly question but do you also want to save these settings later ? If so you can't do it through Qt's resources system since it's read-only.
However what is commonly done when you have a default ini file like that is to copy it to the appropriate place the first time the program is started (using QStandardPaths to retrieve that place) and then use it from there.
Hope it helps
Hi, thank you! Seems that problem is in qmake because everyting ok when i launch it.
The file wasn't compiled ?
Sorry, i think that i said not clearly. I mean that build or run don't help. I don't know the full sequencing for getting this problem again but qmake solve this. This may be same like with adding QDialog class to project and after getting unresolved linking error until launch qmake.