In Qt
5, I have a QDialog
window on which I have drawn a circle as follows:
void MyDialog::paintEvent(QPaintEvent *pe)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing,true);
QPen pen(Qt::blue,2);
painter.setPen(pen);
QRect r=QRect(0,0,100,100);
painter.drawEllipse(r);
}
If I draw a larger circle, for example by using QRect(0,0,500,500);
, the circle being greater than the dialog window is clipped. So I dragged a QScrollArea
onto the the dialog window and decide to draw onto that so that scroll bars are automatically added. The QScrollArea
can be accessed using ui->scrollArea
.
I changed the above code by setting QPainter painter(ui->scrollArea);
. However, nothings appears in the QScrollArea
. I read that I need to override the paintEvent
of QScrollArea
. But I don't know how to do this.
Any help of drawing on the QScrollArea
?