Why this code is not compiled?
-
I try many ways to make this code works, but I don't know to fix it to work, or find another to do the same thing...
Explanations?
I will still reading to find the soluction! Thanks all!ProtocoloFactory.h
@
#ifndef PROTOCOLOFACTORY_H
#define PROTOCOLOFACTORY_H#include <QObject>
#include <bo/protocolo.h>class ProtocoloFactory : public QObject
{
Q_OBJECT
public:
explicit ProtocoloFactory(QObject *parent = 0);Protocolo createLerHistoricoComando();
signals:
public slots:
};
#endif // PROTOCOLOFACTORY_H
@ProtocoloFactory.cpp
@
#include "protocolofactory.h"
#include "bo/protocolo.h"ProtocoloFactory::ProtocoloFactory(QObject *parent) :
QObject(parent)
{
}Protocolo ProtocoloFactory::createLerHistoricoComando()
{
Protocolo retorno(0);
retorno.setOpcode(6);
return retorno;
}
@ -
What is your compiler output error?
And why do you declare empty signal and slots section? If you don't use this, you don't need to declare these section.
-
QtCreator Auto-Generates this section!
Compiler error:
.../InoveBEV/bo/protocolofactory.h:5: In file included from ../InoveBEV/bo/protocolofactory.h:5:0,
.../InoveBEV/bo/protocolofactory.cpp:1: from ../InoveBEV/bo/protocolofactory.cpp:1:
.../bin/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore/qobject.h:-1: In copy constructor 'Protocolo::Protocolo(const Protocolo&)':
.../bin/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore/qobject.h:333: error: 'QObject::QObject(const QObject&)' is private
.../InoveBEV/bo/protocolo.h:7: error: within this context
.../InoveBEV/bo/protocolofactory.cpp:-1: In member function 'Protocolo ProtocoloFactory::createLerHistoricoComando()':
.../InoveBEV/bo/protocolofactory.cpp:13: synthesized method 'Protocolo::Protocolo(const Protocolo&)' first required here