If you have int L then the expression L/2 results in an integer not a float.
Qt4 has only one version of qRound() taking a double, so an implicit cast of integer to double is done and qRound(L/2) compiles cleanly (although you are still "rounding" an integer).
Qt5 has two versions of qRound() taking float or double. Your compiler has raised the new error because it does not know whether to implicitly cast the integer value you have given qRound() to float or double.
Casting to a float the way you have done does not achieve what you think it does. By the time you cast to float you have already done an integer division and discarded the fractional part. There's nothing for qRound() to round even if you then cast the integer result to float or double.
int L = 5;
qDebug() << L / 3; // 1, an integer division
qDebug() << qRound(L / 3); // 1, still an integer division (will not compile under Qt5)
qDebug() << qRound(float(L / 3)); // 1, converting the integer result to float still discards the fractional part
qDebug() << qRound(L / 3.0); // 2, this is forcing floating point division
qDebug() << qRound(qreal(L) / 3); // 2, also a floating point division
int L = 5;
qDebug() << L / 3; // 1, an integer division
qDebug() << qRound(L / 3); // 1, still an integer division (will not compile under Qt5)
qDebug() << qRound(float(L / 3)); // 1, converting the integer result to float still discards the fractional part
qDebug() << qRound(L / 3.0); // 2, this is forcing floating point division
qDebug() << qRound(qreal(L) / 3); // 2, also a floating point division
To copy to clipboard, switch view to plain text mode
If you do revert to Qt4 then you will need a suitable tool chain. The Qt4 binaries distributed at the Qt Project site were built with MingW/GCC 4.4. You appear to be using the GCC 4.8 compiler. There are, if memory serves, binary interface differences between GCC 4.4 and 4.8 that might cause unexpected runtime issues if you mix Qt objects of the old and new binary formats. If you want to use the Qt4 binaries as-is you will need to match the GCC version.
Bookmarks