Nominate our 2022 Qt Champions!

How to get colour value at particular position on custom widget

  • I have written a custom widget using paint event and QPainter inheriting from QWidget. I am drawing tiny random circles with different colors in that widget. I am getting X and Y position using mouse event. How do i get the color which is present at position X and Y . I do not want to use graphics framework to draw tiny circles.

  • You can render your current widget to an image, then get the pixel information from the image.

  • I have drawn it on QPixmap. So is there a way to get it.. ?

Log in to reply