我目前正在嘗試添加滑塊以在OpenGl/QT/C++中的不同軸上移動,但在編譯時會收到模糊的對'main''錯誤的未定義引用。這是我的主類...爲軸添加滑塊時未定義的主引用
我的頭文件:
#include "MyWidget.h"
#ifndef MYMAIN_H
#define MYMAIN_H
class MyMain: public QObject{
public:
MyMain();
int main(int argc, char *argv[]);
MyWidget *MyWidget;
public slots:
void setXTranslation(int value);
};
#endif
我的源文件:
#include "MyMain.h"
MyMain::MyMain()
{
}
int MyMain::main(int argc, char *argv[]) {
some code here...
QSlider *xSlider = new QSlider(Qt::Vertical);
xSlider->setRange(0, 10);
QObject::connect(xSlider, SIGNAL(valueChanged(int)),
this, SLOT(setXTranslation(int)));
some more code here....
// start it running
return app.exec();
}
void MyMain::setXTranslation(int value)
{
some more code here....
}
這使得它編譯感謝:) – Jade