Reputation: 7441
I make some code to communicate with a Qt application. Now I try to refactore this code and I got some problem.
My code is here : https://gist.github.com/abuteau/6f8bd9f072dbb3f61144
When I compile I get invalid use of incomplete type and forward declaration for all the QWidget.
When I code with no namespace I have no error.
How can I solve that ?
Regards,
Upvotes: 0
Views: 115
Reputation: 3252
When you write:
namespace simulatorCommunication {
class QLabel;
class QPushButton;
class QUdpSocket;
...
you say that you will define above classes in your namespace, but they are defined by Qt.
Move forward declarations of those classes above open of your namespace
Upvotes: 2
Reputation: 5874
The class that gives you incomplete type error is not in your namespace. Probably, You have to specify the namespace to the compiler for thos objects. If you gave the compiler error I could be more precise.
Also you do Forward declaration of Qt classe in your own namespace, but these classes will be defined by Qt in the Qt namespace, not yours.
the fwd declaration must be in the namespace where it will be defined
Upvotes: 0