Hi, I'm using Qt4 opensource version on Windows XP. I want to create a simple photo editor program. One of the options is to extract a rectangular part of the image and save it into a new image. The original image can be very large so my idea is to insert the image as a QPixmap in a QLabel and this QLabel is inserted in a QScrollArea. I have subclassed QScrollArea to reimplement the paintEvent method. This is the constructor:

FotoAreaEditor::FotoAreaEditor(EditorFotos *parent)
: QScrollArea(parent)
{
fotoLabel = new QLabel;
fotoLabel -> setScaledContents(true);
fotoLabel -> setPixmap(QPixmap("../book.png"));

setWidget(fotoLabel);
setWidgetResizable(false);
setBackgroundRole(QPalette:ark);
}

In the paintEvent method I create a QPainter object with parent the viewport of the QScrollArea and I try to draw a rectangle on the label just to view the results:

void FotoAreaEditor:aintEvent(QPaintEvent *event)
{
//QScrollArea:aintEvent(event);

QPainter painter(this -> viewport());
painter.setPen(Qt::blue);
painter.setBrush(Qt:ense1Pattern);
painter.drawRect(10, 20, 80, 60);
}

but only the pixmap in the QLabel is painted. And if I don't set any pixmap in the qlabel the rectangle is painted. Does anybody know why?. What am I doing wrong? I dont' have much experience with QPainter...

Thanks.