joksi
27th May 2009, 14:44
I have inherited QListWidget and rewrote the paintEvent()-function as follows:
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);
}
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::setBrush: Painter not active
What is wrong with my code?
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);
}
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::setBrush: Painter not active
What is wrong with my code?