Reputation: 329
I have a project where I need to use an API which expects COLORREF
and another API which returns COLORREF
. COLORREF
is MFC and my project Qt does not want to use any trace of MFC code. COLORREF
is nothing but unsigned long eventually, so I hope there could be a solution.
So there are 2 problems:
COLORREF
and create QColor from this unsigned long number. Please note I cannot use GetRValue()
or GetGValue()
as they would require me to include windows.h
.COLORREF
.Upvotes: 0
Views: 1193
Reputation: 31193
Since COLORREF
is just a DWORD
organized as 0x00bbggrr
, you can easily convert it to components and construct a QColor
out of it.
int r = color & 0xff;
int g = (color >> 8) & 0xff;
int b = (color >> 16) & 0xff;
QColor qc(r, g, b);
Upvotes: 3