how to draw a rectangle on an image label without overloading paintEvent function
i want to draw a rectangle on an image label without overloading paintEvent function......... I don't want to use paintEvent b'coz i have to pas the name of the image to be displayed(frameName) each time I display an image out of a series of images.
Earlier I had drawn suing the following code in the paintEvent function.Now how should I do it without using the paintEvent function.
Code:
if((i >= startFrameMarkerPosition)&&(i < endFrameMarkerPosition))
{
painter.
drawPixmap(0,
0,
QPixmap(localFileName.
at(i
)));
int x,y,w,h;
x=100; y=200; w=TIME_INTERVAL_PROCESSING_PLAY;h=60;
painter.setPen(Qt::red);
painter.drawRect(x,y,w,h);
localSlider->setValue(i);
i++;
}
Thanx in advance!!
Re: how to draw a rectangle on an image label without overloading paintEvent functio
You can use QPainter also direct on the image. So draw on the image and set it to your label.
Re: how to draw a rectangle on an image label without overloading paintEvent functio
I have implemented it as:
Code:
if((i >= startFrameMarkerPosition)&&(i < endFrameMarkerPosition))
{
painter.
drawPixmap(0,
0,
QPixmap(currentFrameName
));
//When this line //is commented,even then the rectangle drawn below is not displayed.Actually neither of them //is working(the 'drawPixmap' and the 'drawRect')
int x,y,w,h;
x=100; y=200; w=80;h=60;
painter.setPen(Qt::red);
painter.drawRect(x,y,w,h);
//QLabel::paintEvent(event);
localSlider->setValue(i);
i++;
}
Can you tell me how to draw on an image!
Re: how to draw a rectangle on an image label without overloading paintEvent functio
Something in the lines of:
Code:
QPixmap myPixmap
(100,
100);
// size
// Use the painter to draw things
// Then use the pixmap like:
myLabel->setPixmap(myPixmap);