Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qfuzzycompare error
Qt 6.11 is out! See what's new in the release blog

qfuzzycompare error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.1k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tactical77
    wrote on last edited by
    #1

    Hi,

    I need to create a Unit test in order to check if 2 floating numbers are equal. Appearetnly you can't use QCompare for that. If I use qfuzzycompare I get the following error.

    test.cpp:36: Fehler: call to 'qFuzzyCompare' is ambiguous
    

    Here's the code.

    void test::testSaldo()
    {
        importieren imp;
    
        qFuzzyCompare(imp.getKonten(12345678)->getSaldo(), 1234.01);
    }
    
    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by JohanSolo
      #2

      What it the signature of your getSaldo() method? I suspect it is float getSaldo or any integer. Both arguments of qFuzzyCompare must have the same type.

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      T 1 Reply Last reply
      7
      • JohanSoloJ JohanSolo

        What it the signature of your getSaldo() method? I suspect it is float getSaldo or any integer. Both arguments of qFuzzyCompare must have the same type.

        T Offline
        T Offline
        tactical77
        wrote on last edited by
        #3

        @JohanSolo

        That was it. Thanks a lot.

        aha_1980A 1 Reply Last reply
        0
        • JohanSoloJ Offline
          JohanSoloJ Offline
          JohanSolo
          wrote on last edited by
          #4

          @tactical77 You're welcome! Please don't forget to mark you question as solved.

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          1 Reply Last reply
          0
          • T tactical77

            @JohanSolo

            That was it. Thanks a lot.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @tactical77

            You CAN use QCOMPARE, because it uses fuzzy compare for doubles behind the scenes, as the linked docu states.

            Regards

            Qt has to stay free or it will die.

            1 Reply Last reply
            5

            • Login

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