Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to specify RGB565 color code in Qt style sheet?
Forum Updated to NodeBB v4.3 + New Features

How to specify RGB565 color code in Qt style sheet?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adaitabehera
    wrote on 8 Jan 2016, 12:11 last edited by
    #1

    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?

    Thanks,
    Adaita

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Jan 2016, 21:33 last edited by
      #2

      Hi,

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 15 Jan 2016, 05:14
      0
      • S SGaist
        8 Jan 2016, 21:33

        Hi,

        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.

        A Offline
        A Offline
        adaitabehera
        wrote on 15 Jan 2016, 05:14 last edited by
        #3

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

        C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Jan 2016, 22:41 last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply 16 Jan 2016, 03:12
          0
          • S SGaist
            15 Jan 2016, 22:41

            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.

            A Offline
            A Offline
            adaitabehera
            wrote on 16 Jan 2016, 03:12 last edited by
            #5

            Very true. I moved the conversion logic to blit() method where I am writing to LCD.

            C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

            1 Reply Last reply
            0

            1/5

            8 Jan 2016, 12:11

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved