Estoy tratando de crear una aplicación GUI simple (hasta ahora) en Qt con C++ usando el compilador MinGW. Sin embargo, el compilador me informa que tengo un multiple definition of 'WiimoteScouter::WiimoteScouter(QWidget*)'
en line 4
de wiimotescouter.cpp
. Estoy usando un cheque para asegurarme de que el encabezado no se incluye varias veces, pero aparentemente no funciona, y no estoy seguro de por qué.C++ Qt Múltiples definiciones
Aquí está el archivo de cabecera:
#ifndef WIIMOTESCOUTER_H
#define WIIMOTESCOUTER_H
#include <QWidget>
class QLabel;
class QLineEdit;
class QTextEdit;
class WiimoteScouter : public QWidget
{
Q_OBJECT
public:
WiimoteScouter(QWidget *parent = 0);
private:
QLineEdit *eventLine;
};
#endif // WIIMOTESCOUTER_H
Y aquí está el archivo CPP:
#include <QtGui>
#include "wiimotescouter.h"
WiimoteScouter::WiimoteScouter(QWidget *parent) :
QWidget(parent)
{
QLabel *eventLabel = new QLabel(tr("Event:"));
eventLine = new QLineEdit;
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(eventLabel, 0, 0);
mainLayout->addWidget(eventLine, 0, 1);
setLayout(mainLayout);
setWindowTitle(tr("Wiimote Alliance Scouter"));
}
Por último, el main.cpp:
#include <QtGui>
#include "wiimotescouter.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
WiimoteScouter wiimoteScouter;
wiimoteScouter.show();
return app.exec();
}
Eso suena más como un error de engarce en lugar de uno de compilador. ¿Tiene más de un archivo .cpp en su archivo .pro? Y publicar el mensaje de error completo ayudaría también. –
¿Por qué tiene su proyecto C++.archivos php en ella? 0_o –
Mi error al copiarlo aquí, es un .cpp, estoy acostumbrado a trabajar con PHP. ;) –