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.
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:
#include <qpainter.h>
QPixmap pixmap(20,10);
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
QPen pen(Qt::blue);
Other similar posts you might be interested to check out:
- April 18, 2010 -- invalid use of incomplete type ‘blah’ (1)
When you try and compile some code and you get an error along the lines of invalid use of an incomplete type 'whatever type' then in most cases it means you need to include the header file where that type is displayed.
For example I had the following events in my header file:
[sourcecode lang="cpp" toolbar="false"]
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
[/sourcecode]
When when I tried to comp... - April 5, 2010 -- Finding an element in a list (0)
Often you need to search through an array or list to find a specific element and of course you need this search to be as fast and efficient as possible. One of the best ways to do this is using a binary predicate function.
A binary function is a function object (which are also called Functors) and is any object which can be called as if it was a function. Depending on your language and platform of choice, Function objects are also known as callback functions, function pointers and delegates (... - March 1, 2010 -- Printing code and making it look pretty (0)
If you are on Linux and want to print some code and also make it look pretty then check out a2ps (Any to postscript filter). Of course if you can avoid printing in the first place and saving paper and trees and make it greener that is ideal - however there are times that is not possible. I tried printing from CDT, but the printing options from CDT just looks plain ugly and big fonts and can spread over 10 pages for a simple code file (spanning 293 lines). Sure I can tweak the font in CDT, but th...
Tags: .code