Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. COLORREF with Qt
Forum Updated to NodeBB v4.3 + New Features

COLORREF with Qt

Scheduled Pinned Locked Moved Solved General and Desktop
colorref
3 Posts 2 Posters 874 Views
  • 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 Offline
    R Offline
    R3dp1ll
    wrote on last edited by
    #1

    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
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • R Offline
        R Offline
        R3dp1ll
        wrote on last edited by
        #3

        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
        0

        • Login

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