qDebug is not printing variable of type QSettings
-
Hello, i am not c++ programmer, i just want to debug Bitcoin-ABC code that I run and got a warning. I solved some issues in other blockchains, and think here it is a simple one but a bit more difficult, that I need more steps, hope you have time for this topic.
Here it is the code, where QSettings variables are declared and used:QSettings // below picks up settings file location based on orgname,appname legacy(legacyOrg, legacyAppName), // default c'tor below picks up settings file location based on // QApplication::applicationName(), et al -- which was already set // in main() abc; const QStringList legacyKeys(legacy.allKeys());
Here it is line that actually gives the error:
const QStringList legacyKeys(legacy.allKeys());
The error when run in terminal on Linux is this:
QVariant::load: unknown user type with name BitcoinUnits::Unit.I try to debug this, and I want to print out content of variable 'legacy' and also abc
//const QStringList legacyKeys(legacyOrg.allKeys()); //error: ‘const class QString’ has no member named ‘allKeys’ //const QStringList legacyKeys; //const QStringList legacyKeys = legacy.allKeys(); //qDebug() << legacyKeys; //qDebug() << legacyOrg; //empty //qDebug() << legacyAppName; //empty qDebug() << legacy; //error: no match for ‘operator<<’ (operand types are ‘QDebug’ and ‘QSettings’) // qDebug() << abc; //error: no match for ‘operator<<’ (operand types are ‘QDebug’ and ‘QSettings’)
but got error:
error: no match for ‘operator<<’ (operand types are ‘QDebug’ and ‘QSettings’)Could you say, if it's possible to print out variable of type QSettings, and how to do that? This is first step to debug this code.
-
You have first of all to get the value from QSettings and print it now using qDebug
something like this.
qDebug() << settings.value("key", defaultValue);
qDebug() << settings.value("key");
check https://forum.qt.io/topic/124607/qsettings-how-to-printout-default-value-of-key/2 -
@Ronel_qtmaster thank you, i read doc for QT5 as actually used https://doc.qt.io/qt-5/qsettings.html and got keys like this:
qDebug() << legacy.allKeys();
keys are:
("DisplayBitcoinUnit", "MainWindowGeometry", "PeersTabBanlistHeaderState", "PeersTabPeerHeaderState", "RPCConsoleWindowGeometry", "RPCConsoleWindowPeersTabSplitterSizes", "RecentRequestsViewHeaderState", "SubFeeFromAmount", "TransactionViewHeaderState", "UseEmbeddedMonospacedFont", "enable_psbt_controls", "fCoinControlFeatures", "fFeeSectionMinimized", "fHideTrayIcon", "fMinimizeOnClose", "fMinimizeToTray", "fReset", "fRestartRequired", "mask_values", "nConfTarget", "nFeeRadio", "nSettingsVersion", "nSmartFeeSliderPosition", "nTransactionFee", "strDataDir", "strThirdPartyTxUrls")also, as mentioned allKeys() gives the error
QVariant::load: unknown user type with name BitcoinUnits::Unit.
I wish to exclude BitcoinUnits::Unit from keys, i hope this will swipe the error. But still do not know how to exclude BitcoinUnits::Unit from the variable 'legacy'. Could you advise something? -
@younicoin Yes i think you have to declare and register the Meta Type BitcoinUnits::Unit. check this https://forum.qt.io/topic/142878/qvariant-unknown-user-type
-