[Qt-interest] regarding drawing rectangles on images

André Somers andre at familiesomers.nl
Mon Dec 14 07:51:46 CET 2009


Hi,

 

Why do you subclass QLabel and then implement drawing of the image yourself?

In your reimplemented paintEvent function, simply call QPixmap::paintEvent
first, and then draw your rectangle on top. And don’t load the image in
every paint event; just set it *once* one the label. 

Alternatively, look into QRubberband. Perhaps that does what you need
already.

 

André

 

 

Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens ankur gupta
Verzonden: zondag 13 december 2009 17:59
Aan: qt-interest at trolltech.com
Onderwerp: [Qt-interest] regarding drawing rectangles on images

 

Hi,
  I am writing an interface using Qt 4.5 . I have to draw editable
rectangles on top of loaded image  . I used Qpixmap to load the image in the
paintEvent function of the class inheriting QLabel .
But , the problem is that the tool is very slow now as it paints the image
every time rectangle is edited .
Is there a better way to do this ?
Please  reply asap . . .

Thanks

-- 
Ankur Gupta

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091214/d065b8d2/attachment.html 


More information about the Qt-interest-old mailing list