If you ever got an error something like [some-class] has initialiser but incomplete type, it basically means the compiler cannot understand the type and you need to add the include for it.

1
2
3
4
5
QPixmap pixmap(20,10);
pixmap.fill(Qt::white);
 
QPainter painter(&pixmap);
QPen pen(Qt::blue);

Take the code snipped above when you compile it you might get an error something along the lines of the following for line 4.

‘QPainter painter’ has initialiser but incomplete type

To fix this you need to include the header file where QPainter is defined. The updated code looks like:

1
2
3
4
5
6
7
#include <qpainter.h>
 
QPixmap pixmap(20,10);
pixmap.fill(Qt::white);
 
QPainter painter(&pixmap);
QPen pen(Qt::blue);