I have inherited QListWidget and rewrote the paintEvent()-function as follows:
void InheritedListWidget
::paintEvent(QPaintEvent *event
) {
painter.
setRenderHint(QPainter::Antialiasing,
true);
};
painter.setBrush(Qt::black);
painter.drawPolygon(points, 3);
}
void InheritedListWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
static const QPointF points[3] = {
QPointF(2,2),
QPointF(this->width()-2,2),
QPointF(2,this->height()-2)
};
painter.setBrush(Qt::black);
painter.drawPolygon(points, 3);
}
To copy to clipboard, switch view to plain text mode
Now, for some reason when I'm running the program, nothing is painted on the list widget and the application prints to console:
QPainter::begin: Paint device returned engine
== 0, type
: 1 QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setBrush: Painter not active
To copy to clipboard, switch view to plain text mode
What is wrong with my code?
Bookmarks