Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. qDebug is not printing variable of type QSettings
Forum Updated to NodeBB v4.3 + New Features

qDebug is not printing variable of type QSettings

Scheduled Pinned Locked Moved Solved The Lounge
4 Posts 2 Posters 635 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    younicoin
    wrote on last edited by younicoin
    #1

    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:

    https://github.com/Bitcoin-ABC/bitcoin-abc/blob/7d99a4ee502feed3adc8c9ca84ac3a18c2822f0e/src/qt/bitcoin.cpp#L540-L553

    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.

    1 Reply Last reply
    0
    • Ronel_qtmasterR Offline
      Ronel_qtmasterR Offline
      Ronel_qtmaster
      wrote on last edited by
      #2

      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

      Y 1 Reply Last reply
      1
      • Ronel_qtmasterR Ronel_qtmaster

        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

        Y Offline
        Y Offline
        younicoin
        wrote on last edited by younicoin
        #3

        @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?

        Ronel_qtmasterR 1 Reply Last reply
        0
        • Y younicoin

          @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?

          Ronel_qtmasterR Offline
          Ronel_qtmasterR Offline
          Ronel_qtmaster
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          1
          • Y younicoin has marked this topic as solved on

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved