I started working on the GUI for an application in C++ using the Qt-Creator and Designer. I always added the new files (cpp, h, ui) by using the dialog that Qt provides.
Here's what I get now:
moc_basewidget.obj:-1: Error: LNK2019: unresolved external signal ""public: void __cdecl BaseWidget::onNewProjects(void)" (?onNewProjects@BaseWidget@@QEAAXXZ)" in function ""private: static void __cdecl BaseWidget::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@BaseWidget@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)".
Here's my BaseWidget.h:
#ifndef BASEWIDGET_H
#define BASEWIDGET_H
#include <QWidget>
#include "mainmenu.h"
#include "projectlist.h"
namespace Ui {
class BaseWidget;
}
class BaseWidget : public QWidget
{
Q_OBJECT
public:
explicit BaseWidget(QWidget *parent = 0);
~BaseWidget();
public slots:
//called in MainMenu
void onProjects();
private:
Ui::BaseWidget *ui;
MainMenu * mainMenu;
ProjectList * projectList;
};
#endif //BASEWIDGET_H
And my BaseWidget.cpp:
#include "basewidget.h"
#include "ui_basewidget.h"
BaseWidget::BaseWidget(QWidget *parent) : QWidget(parent), ui(new Ui::BaseWidget) {
ui->setupUi(this);
//add all the widgets
this->mainMenu = new MainMenu(this);
ui->stackedWidget->addWidget(mainMenu);
this->projectList = new ProjectList(this);
ui->stackedWidget->addWidget(projectList);
}
BaseWidget::~BaseWidget()
{
delete ui;
}
void BaseWidget::onProjects()
{
ui->stackedWidget->setCurrentWidget(this->projectList);
}
And finally, my .pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = GUI
TEMPLATE = app
SOURCES += main.cpp\
basewidget.cpp \
mainmenu.cpp \
projectlist.cpp
HEADERS += basewidget.h \
mainmenu.h \
projectlist.h
FORMS += basewidget.ui \
mainmenu.ui \
projectlist.ui
I've read about it for hours now. I tried cleaning the build-directory and rebuilding, but it always comes down to this.