如何在Qgraphicsview中裁剪图像?
我必须开发一个图像编辑器。我缺少的最后一个功能是使用Qrubberband
裁剪图像,然后使用按钮裁剪所选区域。
有报表有关qgraphicsView
的报告,但我不知道如何将其连接到UI。
I have to develop an image editor. The last feature I'm missing for it is cropping the image using a QRubberBand
, and then crop the selected area using a push button.
There are reports of subclassing QGraphicsView
, but I don't know how to connect it to the UI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您必须构建一个 qrect 与图片区域一起你想保留。
然后,您可以使用复制在qimage上的方法新图片仅包含矩形区域。
使用 qgraphicspixmapitem
接下来
First you have to build a QRect with the area of the picture that you want to keep.
Then you can use the copy method on QImage to create a new picture containing only the rectangle area.
Next use a QGraphicsPixmapItem to add your picture in the scene :
Good luck !