Is there any neat way, short of converting number to QByteArray, to save quint64 with QSettings? The problem is QVariant doesn't accept qint64 nor quint64.
QVariant supports qlonglong and qulonglong. As the documentation says, these are the same as qint64 and quint64. So you can just use QVariant::QVariant(qlonglong) and QVariant::toLongLong.
What if you store qint64 as a string. QString supports such conversion: QString::number(qlonglong n, int base), where qlonglong is the same as qint64. The same for quint64 - use QString::number(qulonglong n, int base), where qulonglong is the same as quint64.
QSettings settings("config.ini", QSettings::IniFormat);
[..]
qint64 largeNumber = Q_INT64_C(932838457459459);
settings.setValue("LargeNumber", QString::number(largeNumber));
[..]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With