Regarding Using QSettings to read INI File
-
This post is deleted! -
@poojakamshetty
It helps if you use code tags for posting this here.values.insert(childKey, settings.value(childKey).toString());
Don't you mean:
QVector<QPair<QString, QString>> values; ... values.insert(i, QPair<QString, QString>(childKey, settings.value(childKey).toString()));
?
Define yourself a type for
QPair<QString, QString>
and this will read easier. -
Hi,
Since you really want a specific order, wouldn't it be simpler to sort your container after loading it with data ? That way you would be a bit less depending on the storage format.
-
@SGaist
Hi
He wants same order as in the ini file so not sure we can sort it out by sorting ;)
Unless you have something magic in mind? -
@mrjj said in Regarding Using QSettings to read INI File:
@SGaist
Hi
He wants same order as in the ini file so not sure we can sort it out by sorting ;)
Unless you have something magic in mind?Nothing magic, but if order is important then maybe sorting the container be a better idea than relying on something that can be modified with a text editor.
-
@SGaist
Absolutely if the order has any logic to it.
Also I'm not sure poster will find QVector easy to access compared to a
map. -
@JonB using this I am getting error.
-
@poojakamshetty said in Regarding Using QSettings to read INI File:
I am getting error
Don't you think you should post the actual error?!
Or should we guess what the error is? -
@jsulm I am sorry, I thought I mentioned error.
main.cpp:29:13: error: no matching member function for call to 'insert'
qvector.h:147:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
qvector.h:148:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
qvector.h:235:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
qvector.h:236:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
qvector.h:149:10: note: candidate function not viable: requires 3 arguments, but 1 was provided
qvector.h:234:14: note: candidate function not viable: requires 3 arguments, but 1 was provided
This is an error.
values.insert(QPair<QString, QString>(childKey, settings.value(childKey).toString()));
At this line, I am getting that error. -
@poojakamshetty Please take a look at QVector documentation for insert() methods and fix your code. Hint: insert() has two parameters (as the error message already suggests).
-
Hi
Actually you might want to use append instead
https://doc.qt.io/qt-5/qvector.html#append
values.append(QPair<QString, QString>(childKey, settings.value(childKey).toString()));