Important: Please read the Qt Code of Conduct -

Call to qRound()/qRound64 is ambiguous.

  • 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.

  • Lifetime Qt Champion


    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 ?

  • @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!

Log in to reply