开发者

How to draw a QPoint on a QGraphicsView/Scene

开发者 https://www.devze.com 2023-01-13 13:06 出处:网络
It\'s really not clear to me how to simply draw a 2d point in QT. I want it to overlay a QPixmap item, but every piece of 开发者_开发知识库documentation I find talks about drawing polygons with brushe

It's really not clear to me how to simply draw a 2d point in QT. I want it to overlay a QPixmap item, but every piece of 开发者_开发知识库documentation I find talks about drawing polygons with brushes.

Thanks in advance -


From Qt's documentation:

QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen.

So if you have a QPixmap, convert it to QImage and then use QImage::setPixel:

QImage image = pixmap->toImage();
image.setPixel(2, 4, 0x0000ff);
ui->label->setPixmap(QPixmap::fromImage(image)); // show the image in a label
0

精彩评论

暂无评论...
验证码 换一张
取 消