Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved COLORREF with Qt

    General and Desktop
    colorref
    2
    3
    444
    Loading More Posts
    • 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.
    • R
      R3dp1ll last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        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 )

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 2
        • R
          R3dp1ll last edited by

          Yeah it was simple... I thought Qt had the same basic library tools as VS.

          And now, it works. thank you.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post