How to specify RGB565 color code in Qt style sheet?
I need to specify background color for widgets which will be rendered on an LCD of 16 bit color depth. I got the color codes from graphics designer in RGB888 format and converted them to RGB565.
Suppose I have to set the background color of a label to #9BCFDC in RGB888 which converts to #9E7B in RGB565. As per Qt's stylesheet documentation the color code can be specified as #HHH or #HHHHHH format. Do I need to specify the color as #009E7B?
I may be wrong, but IIRC, you should still use the RGB888 notation. QColor works with RGB888. It should be the backend that does the final conversion to paint in RGB565.
@SGaist You are right for the case where someone is using the frame buffer. The default implementation of QScreen::blit() method calls the private method qt_blit_setup() which actually takes care of the color depth. However, I am not using frame buffer. I am using QScreenDriverPlugin and subclassing QScreen that reimplements blit() method where it writes to the LCD. Using the 16 bit color code (e.g. #009E7B) in stylesheet works for me, but I think it is a dirty solution. I should handle this before writing to the LCD.
I confirm, it's an abuse of the system that might bite you back if someone tries to change the values in the style sheet and doesn't know that he has to use the 16bit notation.
Very true. I moved the conversion logic to blit() method where I am writing to LCD.