[Qt-interest] How can I draw lines on QLabel ?

Andre Somers andre at familiesomers.nl
Mon Aug 31 16:09:05 CEST 2009


st_322 wrote:
> Hi,all
> I am a fresh of Qt,I use QLabel displayed a image file(bmp format),but 
> don't know how to draw lines over it.Dose someone know the question 
> and resolving method? Thanks a lot.
>
The same way you would with any QWidget subclass:

subclass QLabel, and reimplement it's paintEvent( QPaintEvent* event ) 
method. In your reimplementation, first call the base implementation 
like this:
QLabel::paintEvent(event);

Now, create a QPainter on your widget, and do your own painting using 
that painter.


Instead of a QLabel, instantiate your own subclass in your program.

Andr¨¦




More information about the Qt-interest-old mailing list