0

这似乎微不足道,但找不到解决方案。我需要在 QGraphicsScene 上读取某个 x,y 点的颜色。就像是graphScen->colorAt(x,y);

4

1 回答 1

0

QGraphivsScene 不知道点上的颜色,而且它并不是微不足道的(您在场景和项目上都有转换)。您可以做的是访问渲染场景的像素图并访问那里的像素信息。

QPixmap paintDevice(sceneBoundingRect());
QPainter painter(&paintDevice);
graphScen->render(painter);
// Now you have the pixmap, get the pixel information.
QImage pixels = paintDevice.toImage();
QRgb colorAt = pixels.pixel(x,y);

完毕。

于 2017-04-05T07:54:59.293 回答