qt_user
6th August 2010, 08:00
I have already made a video player(it runs different frames according to a timer) on a "QLabel"(not a QScrollArea)......now I have added another functionality that when the "process" button is clicked, the images are displayed along with some rectangles......For this I have used QPainter class's drwaPixel() and drwaRectangle() functions.................but both the functions are not displaying anything on the Label..........Here is the part of the code for the newer(process) functionality..........
void VideoDisplayer::processNextPicture()
{
if((i >= startFrameMarkerPosition)&&(i < endFrameMarkerPosition))
{
//videoLabel->setPixmap(QPixmap(localFileName.at(i)));
//I used this function for the earlier case(normal video display without process functionality) and it works fine but it can't be used now otherwise the drawRectangle() function doesn't work over it
// QFrame::paintEvent(event);
QPainter painter(videoLabel);
painter.drawPixmap(0,0,400,400,QPixmap(localFileNa me.at(i)));
//painter.drawPixmap(0,0,100,100,QPixmap(":/images/frame0000.png"));
int x,y,w,h;
x=100; y=200; w=80;h=60;
painter.setPen(Qt::red);
painter.drawRect(x,y,w,h);
videoLabel->adjustSize();
//videoLabel->setScaledContents(true);
localSlider->setValue(i);
videoLabel->show();
i++;
}
This code displays nothing on the label
I have also tried using the paintEvent function by defining it with the similar contents and calling it in place of the above code by repaint();This showed me that the paint function is getting called but the drawRectangle() and drawPixmap() on a QLabel are the real culprits.......please suggest a solution......thanx in advance
void VideoDisplayer::processNextPicture()
{
if((i >= startFrameMarkerPosition)&&(i < endFrameMarkerPosition))
{
//videoLabel->setPixmap(QPixmap(localFileName.at(i)));
//I used this function for the earlier case(normal video display without process functionality) and it works fine but it can't be used now otherwise the drawRectangle() function doesn't work over it
// QFrame::paintEvent(event);
QPainter painter(videoLabel);
painter.drawPixmap(0,0,400,400,QPixmap(localFileNa me.at(i)));
//painter.drawPixmap(0,0,100,100,QPixmap(":/images/frame0000.png"));
int x,y,w,h;
x=100; y=200; w=80;h=60;
painter.setPen(Qt::red);
painter.drawRect(x,y,w,h);
videoLabel->adjustSize();
//videoLabel->setScaledContents(true);
localSlider->setValue(i);
videoLabel->show();
i++;
}
This code displays nothing on the label
I have also tried using the paintEvent function by defining it with the similar contents and calling it in place of the above code by repaint();This showed me that the paint function is getting called but the drawRectangle() and drawPixmap() on a QLabel are the real culprits.......please suggest a solution......thanx in advance