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...
I will still reading to find the soluction! Thanks all!
class ProtocoloFactory : public QObject
explicit ProtocoloFactory(QObject *parent = 0);
#endif // PROTOCOLOFACTORY_H
ProtocoloFactory::ProtocoloFactory(QObject *parent) :
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!
.../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
If Protocolo is a QObject, then your ProtocoloFactory::createLerHistoricoComando() method will not work, as it's relying on returning a copy of the Protocolo object created in line 11. QObjects are non-copyable by their nature.
I that case I will need use Reference (*)?
Or Cannot be done what I want?!
You would need to use new to create the object on the heap and return a pointer to it, ideally a smart pointer.
Thanks mlong, I will do that and study the necessary.