Hi,
the other threads didn't help me out.
My code worked so far, but now I tried to connect the Buttons to their function.
Each time I add Q_OBJECT to the mainWindow.h, I get the following errors:

1>mainWindow.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual struct QMetaObject const * __cdecl mainWindow::metaObject(void)const " (?metaObject@mainWindow@@UEBAPEBUQMetaObject@@XZ)" .
1>mainWindow.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual void * __cdecl mainWindow::qt_metacast(char const *)" (?qt_metacast@mainWindow@@UEAAPEAXPEBD@Z)".
1>mainWindow.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual int __cdecl mainWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@mainWindow@@UEAAHW4Call@QMetaObject@ @HPEAPEAX@Z)".
1>mainWindow.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: static struct QMetaObject const mainWindow::staticMetaObject" (?staticMetaObject@mainWindow@@2UQMetaObject@@B)".
1>C:\Users\Stefanie\Desktop\Bachelorarbeit\Projekt \v05\build\Debug\ProgramExec.exe : fatal error LNK1120: 4 nicht aufgelöste Externe

And if I don't use it the connects are not working. (No surprise...)


My code:


main.cpp:
#include <iostream>

// needs to be included before gl.h
#include <GL/glew.h>

#include <QApplication>
#include <QtGui>
#include <QGLFormat>

#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>

#include <QCheckBox>
#include <QComboBox>

#include "gui/openglwindow.h"

#include <QFileDialog>
#include "gui/mainWindow.h"
#include <QMessageBox>


int main( int argc, char *argv[] ) {
// create application and pass arguments
// QT parses args and returns unused args for your usage
QApplication app(argc, argv);

// create main window of our application
// you have to pass the application object
mainWindow *win = new mainWindow();

// report main window to the application
app.setActiveWindow(win);

// set initial size
win->resize(1240,640);

// show the window
win->show();

app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
win->connectAll();

return app.exec();
}


mainWindow.h:
#pragma once

#include <iostream>
#include <QMainWindow.h>

#include <GL/glew.h>

#include <QApplication>
#include <QtGui>
#include <QGLFormat>

#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>

#include <QCheckBox>
#include <QComboBox>

#include "gui/openglwindow.h"
#include "ui_settings.h"

#include <QFileDialog>
#include "ObjLoader/ObjLoader.h"
#include <QMessageBox>

class mainWindow : public QMainWindow
{
Q_OBJECT At this line is the Problem.
public:
mainWindow(void);
OpenGLWindow *renderView; I already tried taking everything out with this class, but it didn't make any difference.
void connectAll(void);

public slots:
void doChooseButton(void);
void doDisplayCombo(int count);
void doLoadButton(void);
void doChooseResolutionBox(int count);
void doSelectButton(void);
void doNormalResolutionBox(bool normal);

private:
Ui::SettingsForm ui_main;
int displayComboCounter;
int resolutionCounter;

protected:

};


mainWindow.cpp:
#include "mainWindow.h"
#include <QMenu>
#include <QMenuBar>



mainWindow::mainWindow(): QMainWindow(){
QWidget *centralWidget = new QWidget(this);

QHBoxLayout *hboxLayout = new QHBoxLayout(centralWidget);

// 2D widget
QGLFormat format;
format.setVersion(4,1);
format.setProfile(QGLFormat::CompatibilityProfile) ;
format.setSampleBuffers(true);
format.setSamples(4);
QGLFormat::setDefaultFormat(format);

renderView = new OpenGLWindow(format);
renderView->setMinimumSize(QSize(400, 400));

// main window
hboxLayout->addWidget(renderView);


QWidget *dialog = new QWidget();

ui_main.setupUi(dialog);
hboxLayout->addWidget(dialog);
setCentralWidget(centralWidget);

//TEST because slots do not work


}


void mainWindow::connectAll(){
connect(ui_main.chooseButton, SIGNAL(clicked()), this, SLOT(doChooseButton()));
connect(ui_main.displayCombo, SIGNAL(activated(int)), this, SLOT(doDisplayCombo(int)));
connect(ui_main.loadButton, SIGNAL(clicked()), this, SLOT(doLoadButton()));
connect(ui_main.chooseResolutionBox, SIGNAL(activated(int)), this, SLOT(doChooseResolutionBox(int)));
connect(ui_main.selectButton, SIGNAL(clicked()), this, SLOT(doSelectButton()));
connect(ui_main.normalResolutionBox, SIGNAL(toggled(bool)), this, SLOT(doNormalResolutionBox(bool)));
}


void mainWindow::doChooseButton(void){

QString selfilter = tr("Model (*.obj)");
try{
QString filename = QFileDialog::getOpenFileName(this, "Choose Object-File", "C:\\", tr("Model(*.obj);;All files (*.*)"),&selfilter);
if(filename.length()!= 0){
QByteArray ba = filename.toLocal8Bit();
const char *charFilename = ba.data();
// TODO ObjLoader* m_Mesh_test = new ObjLoader(tr(charFilename));
if (/* TODO m_Mesh_test->isValid() &&*/ filename.endsWith(".obj")){
if(ui_main.displayCombo->findText(filename) == -1){
ui_main.displayCombo->addItem(filename);
}else{
QMessageBox msgBox;
msgBox.setText("This file is already existent.");
msgBox.exec();
}
}else{
QMessageBox msgBox;
msgBox.setText("This file has the wrong type.");
msgBox.exec();
}
}
}catch(int){

}
}


void mainWindow::doDisplayCombo(int count){
displayComboCounter = count;
}


void mainWindow::doLoadButton(void){

}


void mainWindow::doChooseResolutionBox(int count){
resolutionCounter=count;
}


void mainWindow::doSelectButton(void){

}


void mainWindow::doNormalResolutionBox(bool normal){

}


It would be really nice, if anyone could help me out. I already deleted the build folder a few times. No difference.