[Qt-interest] QBitArray and QSettings
Bob Hood
bhood2 at comcast.net
Sat Aug 22 18:30:08 CEST 2009
I'm not seeing a direct (obvious) way to store a QBitArray into a
QSettings object in the same way I can with other types, so I wrote a
pair of methods to convert to/from QString:
QString MainWindow::bit_array_to_string(const QBitArray& array)
{
QString str;
for(int i = 0;i < array.size();i++)
str += (array[i] ? "1" : "0");
return str;
}
QBitArray MainWindow::string_to_bit_array(const QString& string)
{
QBitArray array;
array.resize(string.size());
for(int i = 0;i < string.size();i++)
array[i] = (string[i] == '1');
return array;
}
Must a QBitArray be converted to some other type before it can be stored
and retrieved via a QSettings object, or did I just miss a
less-than-obvious interface?
Render me gone, |||
Bob ^(===)^
---------------------------------oOO--(_)--OOo---------------------------------
The amount you paid for your vehicle does not determine the degree
to which driving laws will apply to you. Sorry.
More information about the Qt-interest-old
mailing list