Unsolved Stupid Question need smart answer "incomplete type"
-
Hi,
I forgot to add QPixmap in one of the header file which there is a QPixmap slot I got error :
"QPixmap incomplete type"
It took a whiiiiiiiiiile . to realize to include QPixmap to the .h file. Thats fine.
Isn there any tooling in QtCreator to warn me that I should include QPixmap instead of compiler errors :)
like Java world asking automatic adding the library :)
-
That is what that compiler message is telling you.
-
Hi
The compiler cannot possible know what to include to have a certain type defined.
Since You can create any number of Types and save in randomly names .cpp / .h file
its not so easy to have it give suggestions. -
Hi,
if you use a Qt-Type just have a look at the documentation.
For QPixamp see http://doc.qt.io/qt-5/qpixmap.html
At the top there´s always any header to include and also the qt modules to provide to qmake. -
@sneubert said in Stupid Question need smart answer "incomplete type":
At the top there´s always any header to include and also the qt modules to provide to qmake.
Hi @sneubert
There are no stupid questions, just thoughtless answers!
@mrjj and the others are correct with their thoughtful answer. The only thing I would have added is that header files and constructor lists and pointers are kept happy by forward declarations in C++. I am sure you know what I mean. The GNU compiler seems to be happy even with a non-pointer declaration in a class when there is a forward declaration as long as it is not used inline.
Just know, if you see that error message (and I have too) because if you like to keep nested includes to a minimum or keep functionality hidden then remember to include the header in your CPP file. You don't always have to include the headers in your header file. That is purely a design consideration.
-
@Buckwheat said in Stupid Question need smart answer "incomplete type":
You don't always have to include the headers in your header file. That is purely a design consideration.
Nope, that's also a compile-time question. Cramming your header full of all unneed includes can push your compile time up, rather quickly in fact.
-
@J.Hilk said in Stupid Question need smart answer "incomplete type":
hat's also a compile-time question. Cramming your header full of all unneed includes can push your compile time up, rather quickly in fac
@J-Hilk
You are correct if you never use instances. I hate unnecessary includes for that reason. Some designs require non-pointer members so including the headers is a must. The rule is... only include what you need to cleanly compile and test your object. So, again, it is a design matter.Unfortunately, some advice is given to "just include the header because its in the docs" or young developers just think they have to do it that way and senior developers seem to not want to take the time to mentor young programmers to engineer proper software.
-
Hi @Buckwheat
are you related to Roland Hughes from Logikal Solutions?