Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
int to quint8
-
Hi,
How can I convert "int" to "quint8" and "quint8" to "int"?
-
int a = 5;
quint8 b = a;
a = b;
-
you can use static cast
int a = 1; qint8 b=static_cast<qint8>(a);
-
modern C++ has this really annoying warning called "narrowing conversions". you have to limit the range of the input value using bitwise AND 0xff... of whatever size the target is, then do a static_cast<> to the target type.