qtcolorsqmlrgbrgba

QML: Any way of using the standard integer RGB values?


I'm using Qt 5.7 on Windows 10 and I'm relatively new to QML. I am currently adding some colors to my application and it struck me that there seems to be no way of using the plain integer RGB values (not hexadecimals) for colors. There are (as far as I know) three direct ways (without using the Qt C++ functions of QColor in combination with the QML code) of setting an item to a specific color:

All three coloring conventions above represent the same color (RGB: 128, 128, 128). I really prefer using the normal integer values since I'm more familiar with those. Is it possible to use those without any extra effort in QML?


Solution

  • No.

    Building off what @Gwen said, you can define your own function that takes integers and does the conversion to floats, and then call that everywhere.