Hi,
saving values with qsettings works out of the box for "normal" variables (not pointers), but with pointer variables it doesn't work.
WORKING VERSION:
int myInt;
settings->beginGroup("lol");
myString = settings->value("myString").toString();
myInt = settings->value("myInt").toInt();
settings->endGroup();
std::cout << qPrintable(myString) << std::endl;
std::cout << myInt << std::endl;
QString myString;
int myInt;
settings = new QSettings("test", "lol");
settings->beginGroup("lol");
myString = settings->value("myString").toString();
myInt = settings->value("myInt").toInt();
settings->endGroup();
std::cout << qPrintable(myString) << std::endl;
std::cout << myInt << std::endl;
To copy to clipboard, switch view to plain text mode
NOT WORKING VERSION
int *myInt = new int;
settings->beginGroup("lol");
*myString = settings->value("myString").toString();
*myInt = settings->value("myInt").toInt();
settings->endGroup();
std::cout << qPrintable(*myString) << std::endl;
std::cout << *myInt << std::endl;
QString *myString = new QString;
int *myInt = new int;
settings = new QSettings("test", "lol");
settings->beginGroup("lol");
*myString = settings->value("myString").toString();
*myInt = settings->value("myInt").toInt();
settings->endGroup();
std::cout << qPrintable(*myString) << std::endl;
std::cout << *myInt << std::endl;
To copy to clipboard, switch view to plain text mode
can anyone explain me why qsettings with pointer variables doesn't work?
Or where i am wrong?
Bookmarks