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. Call to qRound()/qRound64 is ambiguous.
Forum Update on Monday, May 27th 2025

Call to qRound()/qRound64 is ambiguous.

Scheduled Pinned Locked Moved Solved General and Desktop
c++qround
3 Posts 2 Posters 809 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.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #1

    Good evening,
    I hope someone will help me understand. Seems like something obvious that I miss here. (Qt 5.15.2, multios)

    The case is really simple, I want to display the file size in kB. QFileInfo::size() returns bytes.
    So, I built my QString:

    QFileInfo info;
    // fill the data, load the file, etc. rubbish
    QString fsize = QString("%1 kB").arg(qRound64(info.size()/1024));
    

    And I get this error. Of course, same for usual qRound. I don't use math methods very often...
    What is ambiguous here?

    Many thanks in advance.

    For more information please re-read.

    Kind Regards,
    Artur

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are dividing two integers. You can use 1024.0 or explicitly cast it in order to get either a double or a float which is what qRound and qRound64 are expecting.
      But first why trying to round an integer value ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      artwawA 1 Reply Last reply
      5
      • SGaistS SGaist

        Hi,

        You are dividing two integers. You can use 1024.0 or explicitly cast it in order to get either a double or a float which is what qRound and qRound64 are expecting.
        But first why trying to round an integer value ?

        artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #3

        @SGaist imagine me doing glorious facepalm...
        I jump between three languages recently and somehow I was deeply convinced that result will be a floating point value...

        Shame on me.
        Thank you for clarifying!

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        0

        • Login

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