Zanyinj
17th September 2012, 15:24
Good day.
I have an application that has its own settings file, which I generate with Qt and load with Qt. I am using QSettings::IniFormat, because i want to be able to change these settings by hand if needed.
new QSettings("myconfig.cfg", QSettings::IniFormat);
It works like a charm, the only problem is when i do a setValue() with a QVariantList that only has one value.
My QVariantLists QVariants are all QRects.
e.g: When the list contains two rectangles,
QList<QRect> testList;
testList.append(QRect(0,0,1,1));
testList.append(QRect(1,1,1,1));
QList<QVariant> variantList;
foreach(QRect rect, testList)
{
variantList.append(rect);
}
m_settings->setValue(QString("rememberRectList"), variantList);
the configuration file's entry looks ok:
rememberRectList=@Rect(0 0 1 1), @Rect(1 1 1 1)
But, when the list contains only a single entry:
...
QList<QRect> testList;
testList.append(QRect(0,0,1,1));
QList<QVariant> variantList;
foreach(QRect rect, testList)
{
variantList.append(rect);
}
m_settings->setValue(QString("rememberRectList"), variantList);
...
I get this:
rememberRectList=@Variant(\0\0\0\t\0\0\0\x1\0\0\0\ x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
I am wondering if this is a bug or am I doing something wrong.
Thank you.
I have an application that has its own settings file, which I generate with Qt and load with Qt. I am using QSettings::IniFormat, because i want to be able to change these settings by hand if needed.
new QSettings("myconfig.cfg", QSettings::IniFormat);
It works like a charm, the only problem is when i do a setValue() with a QVariantList that only has one value.
My QVariantLists QVariants are all QRects.
e.g: When the list contains two rectangles,
QList<QRect> testList;
testList.append(QRect(0,0,1,1));
testList.append(QRect(1,1,1,1));
QList<QVariant> variantList;
foreach(QRect rect, testList)
{
variantList.append(rect);
}
m_settings->setValue(QString("rememberRectList"), variantList);
the configuration file's entry looks ok:
rememberRectList=@Rect(0 0 1 1), @Rect(1 1 1 1)
But, when the list contains only a single entry:
...
QList<QRect> testList;
testList.append(QRect(0,0,1,1));
QList<QVariant> variantList;
foreach(QRect rect, testList)
{
variantList.append(rect);
}
m_settings->setValue(QString("rememberRectList"), variantList);
...
I get this:
rememberRectList=@Variant(\0\0\0\t\0\0\0\x1\0\0\0\ x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)
I am wondering if this is a bug or am I doing something wrong.
Thank you.