[Interest] draw text and shape on an image using QGraphicsView
Mehmet İpek
mhmtipek at gmail.com
Mon Jul 16 12:19:38 CEST 2012
I suggest you to create a QGraphicsTextItem in mousePressEvent function.
Don't use QPainter to draw graphics if you are using QGraphicsView. Btw,
your code shouldn't be compiled. QPainter constructor takes QPaintDevice*
and you are giving QGraphicsScene* which is derived from QObject.
On Sun, Jul 15, 2012 at 5:14 PM, Arun Kumar <arunkumaraymuo at gmail.com>wrote:
>
> Hello,
> I am trying to create a simple image editing tool using Qt GraphocsView
> I can load any image file to QGraphicsView
>
>
> now I am trying to add some text in loaded image. For that I subclass
> QGraphicsView and override
>
>
> mousePressEvent(QMouseEvent* event)
>
>
> I tried this code to draw a string on the clicked position of image but it not displaying any string in image
>
>
> void GraphicsViewExt::mousePressEvent(QMouseEvent* event) {
> //For panning the view
> LastPanPoint = event->pos();
>
> QPainter painter(this->scene());
> painter.setRenderHint(QPainter::Antialiasing);
> // this->scene()->render(&painter);
> painter.drawText(LastPanPoint.x(),LastPanPoint.y(),"Test String");
>
> //this->invalidateScene();
>
> }
>
>
>
> How I can draw a string on an image when the user click on the image. I searched net but didnt get any solution to this simple problem?
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120716/81755dd8/attachment.html>
More information about the Interest
mailing list