Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ QT QT-Creator
I am creating a simple Image Editing tool to draw a shape on image using Qt. I can load Image to QGraphicsView. I tried sub classing QGraphicsScene and override mouse press event. But don't know how to draw a line on the image where the mouse pressed.
 
How to draw a line or any text on a Bitmap image using Qt
Posted 17-Jul-12 22:09pm
Comments
Amarnath S at 18-Jul-12 23:52pm
   
A quick search for "qt rubber band line" yields these results:
http://www.qtcentre.org/threads/3596-Draw-rubberband-line
 
http://lists.trolltech.com/qt-interest/2001-12/thread00642-0.html
 
See also:
http://doc.qt.nokia.com/4.7-snapshot/painting-basicdrawing.html
 
In the above, they have drawn a rectangle, you need to modify this to draw a line. Also make sure that you're painting the bitmap before drawing the line, so this gives the appearance that the line is drawn on the image. A similar method for drawing text.
 
To achieve a flicker-free performance, you need to do double-buffering:
http://doc.qt.nokia.com/qq/qq06-flicker-free.html#doublebuffering
Arun Kumar K S at 18-Jul-12 23:55pm
   
Surewly I will check your suggestion.., But I need to save the new image
Amarnath S at 19-Jul-12 0:15am
   
Look at this example:
http://doc.qt.nokia.com/4.6/widgets-scribble.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 18 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100