Search code examples
qtqtgui

Why is Qt QColor a part of QtGUI - possible workarounds?


I'm building a commandline version of an an application that utilizes QColor for cross-platform handling of color data.

For some reason, this datatype is a part of QtGUI even thou it doesn't have anything to do with Widgets - any way to get this class without linking with GUI?


Solution

  • Probably because it includes all the hooks into the QPainter class to draw colors. Yes in a perfect design it would be possible to abstract all that away, but Qt is mostly a gui library and time is money.

    But since it's open source you can just copy the Qcolor .h/.cpp and modif them yourself. If you only need the color space conversion routines you can probably just use the.h

    Note: Qt is LGPL so the source to any modifications to the Qt code (but not your own app) must be offered to any users of your app.