How can I draw with brush on QLabel?
I have QLabel on the form. I use it to show an image like this:
Code:
ui
->label
->setPixmap
(QPixmap::fromImage(image.
scaled(349,
228, Qt
::KeepAspectRatio, Qt
::FastTransformation)));
ui->label->adjustSize();
How can I paint with brush on my QLabel with mouse? For example, i press left mouse key, then dragging, it lefts brush'es line, then the results - on the QLabel.
Re: How can I draw with brush on QLabel?
erm, I don't think you should be using a QLabel for that. Take a look at QPainter. QLabel is for displaying text (or an image)
Re: How can I draw with brush on QLabel?
Quote:
Originally Posted by
genjix
erm, I don't think you should be using a QLabel for that. Take a look at QPainter. QLabel is for displaying text (or an image)
in my programm i use QLabel for displaying an image, and i want to draw on this image (QLabel) with mouse pointer. How can i do it?
Re: How can I draw with brush on QLabel?
Reimplement paint event and mouse events for the widget.
Re: How can I draw with brush on QLabel?
What is the benefit of creating a QImage and then immediately converting it to a QPixmap?
For painting: Reimp all needed mouse event handlers and then either using QPainter and draw an the QPixmap or store all lines etc. call update() and do the drawings at the paint event.
EDIT: Just found out, that my browser has a refresh button. Maybe I should use it from time to time...