Results 1 to 3 of 3

Thread: How to get color of pixel or point?

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question How to get color of pixel or point?

    Hi all,

    I have a QWidget with this style sheet:

    background: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(0, 0, 0), stop: 1 rgb(255, 255, 255));

    How can I get the color in each point?

    Regards.

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: How to get color of pixel or point?

    First Google hit for 'qwidget get pixel' is http://www.qtcentre.org/threads/3096...w-mouse-Cursor and should show you how.

  3. #3
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get color of pixel or point?

    I have used this code and seems that works fine:

    Qt Code:
    1. QPixmap qPix = QPixmap::grabWidget(ui->myWidget);
    2. QImage image(qPix.toImage());
    3. QColor color(image.pixel(0, 1));
    To copy to clipboard, switch view to plain text mode 

    Thanks!

Similar Threads

  1. how can a pixel be a floating point number
    By babu198649 in forum General Programming
    Replies: 1
    Last Post: 2nd June 2008, 19:05
  2. Point to Pixel Calculation on all screen
    By patrik08 in forum General Programming
    Replies: 0
    Last Post: 3rd April 2008, 09:10
  3. getting color from a pixel on canvas
    By teeshift in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 05:12
  4. How to get color of pixel or point by QMouseEvent
    By Krishnacins in forum Newbie
    Replies: 4
    Last Post: 28th May 2006, 02:46
  5. How to convert pixel to point & vs
    By Krishnacins in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 17:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.