COLORREF with Qt
Solved
General and Desktop
-
hello,
I have a problem with the use of COLORREF with Qt.
I made this piece of code on visual studio:
#include <windows.h> #include <stdio.h> int main() { Sleep(2000); //create the coords int xPixelColor = 829; int yPixelColor = 1021; //flash the pixel color and stock it HDC dc = GetDC(NULL); COLORREF color = GetPixel(dc, xPixelColor, yPixelColor); ReleaseDC(NULL, dc); // find RGV int red = GetRValue(color); int green = GetGValue(color); int blue = GetBValue(color); std::cout << red << green << blue; }
it works perfectly.
Copy pasted under Qt and hop it does not compile anymore: "undefined reference to `_imp_GetPixel@12'
Yet I put the same includes ...
There, I'm lost, an idea? -
According to MSDN ( https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-getpixel ) GetPixel is available in Gdi32.lib so you should link to gdi32.lib ( http://doc.qt.io/qt-5/qmake-variable-reference.html#libs )