my current implementation of paintEvent is this
(it's not a real rose, I know, it's just a test)
{
painter.
setRenderHint(QPainter::Antialiasing,
true);
painter.
setPen(QPen(Qt
::black,
12, Qt
::DashDotLine, Qt
::RoundCap));
painter.
setBrush(QBrush(Qt
::green, Qt
::SolidPattern));
painter.drawEllipse(80,80,200,240);
}
void myScrollArea::paintEvent(QPaintEvent* event)
{
QScrollArea::paintEvent(event);
QPainter painter(viewport());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap));
painter.setBrush(QBrush(Qt::green, Qt::SolidPattern));
painter.drawEllipse(80,80,200,240);
}
To copy to clipboard, switch view to plain text mode
Instead of using 'viewport()' I also tried 'this' and 'widget()' as an object to paint on. I received the following error for both trials, and neither one painted anything at all.
QPainter::begin: Widget painting can only begin as a result of a paintEvent
Painter must be active to set rendering hints.
Bookmarks