Why do I get the following error when using QPainter: QPainter::begin: Paint device returned engine == 0, type: 1?

This error can occur if you try to use the painter on a subclass of QScrollArea [doc.qt.nokia.com], and you don’t pass in the viewport() [doc.qt.nokia.com] as the device to paint on. So if you are painting on a QTableWidget [doc.qt.nokia.com] for instance, make sure you instantiate the painter as follows:

  1. QPainter painter(tableWidget->viewport());
  2.  

No comments

Write a comment

Sorry, you must be logged in to post a comment.