I have inherited QListWidget and rewrote the paintEvent()-function as follows:

Qt Code:
  1. void InheritedListWidget::paintEvent(QPaintEvent *event)
  2. {
  3. QPainter painter(this);
  4. painter.setRenderHint(QPainter::Antialiasing, true);
  5.  
  6. static const QPointF points[3] = {
  7. QPointF(2,2),
  8. QPointF(this->width()-2,2),
  9. QPointF(2,this->height()-2)
  10. };
  11. painter.setBrush(Qt::black);
  12. painter.drawPolygon(points, 3);
  13. }
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:

Qt Code:
  1. QPainter::begin: Paint device returned engine == 0, type: 1
  2. QPainter::setRenderHint: Painter must be active to set rendering hints
  3. QPainter::setBrush: Painter not active
To copy to clipboard, switch view to plain text mode 

What is wrong with my code?