मुझे पता है कि सवाल कई बार पूछा गया है लेकिन मुझे यहां समाधान और Google में समाधान नहीं मिल रहा है।QObject: गायब vtable लिंक त्रुटि
यहाँ मेरी हेडर फाइल
#ifndef MAINCONTROLLER_H
#define MAINCONTROLLER_H
#include <QSettings>
#include <QDebug>
#include <QDir>
#include <QObject>
#include "PhTools/PhString.h"
#include "PhStrip/PhStripDoc.h"
class MainController : public QObject
{
Q_OBJECT
public:
explicit MainController(QObject *parent = 0);
void loadSettings();
PhString getLastFile();
void setLastFile(PhString fileName);
bool openDoc(PhString fileName);
signals:
void docChanged();
private:
QSettings * _settings;
PhStripDoc * _doc;
};
#endif // MAINCONTROLLER_H
और मेरे सीपीपी फ़ाइल है:
#include "MainController.h"
MainController::MainController(QObject *parent) :
QObject(parent)
{
_doc = new PhStripDoc();
loadSettings();
}
void MainController::loadSettings()
{
_settings = new QSettings(QDir::homePath() + "/Library/Preferences/com.me.me.plist", QSettings::NativeFormat);
getLastFile();
}
PhString MainController::getLastFile()
{
qDebug() << "lastfile :" << _settings->value("last_file", "").toString();
return _settings->value("last_file").toString();
}
bool MainController::openDoc(PhString fileName)
{
bool succeed = _doc->openDX(fileName);
if (succeed)
emit docChanged();
return succeed;
}
void MainController::setLastFile(PhString filename)
{
_settings->setValue("last_file", filename);
}
और यहाँ त्रुटि लॉग है:
Undefined symbols for architecture x86_64:
"MainController::docChanged()", referenced from:
MainController::openDoc(QString) in MainController.o
"vtable for MainController", referenced from:
MainController::MainController(QObject*) in MainController.o
MainController::MainController(QObject*) in MainController.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
यह signals
से आ सकते हैं, लेकिन मैं नहीं कर रहा हूँ सुनिश्चित करें ...
संभावित डुप्लिकेट [वर्चुअल फ़ंक्शन के साथ क्लास, क्यूओब्जेक्ट से प्राप्त होने पर, लिंकिंग त्रुटि की ओर जाता है] (http://stackoverflow.com/questions/7103964/class-with-virtual-function-when-derived-from-qobject -लेड्स-टू-लिंकिंग-एरर) –
(कई अन्य डुप्लिकेट हैं) –
@ मैट्स पीटरसन: अच्छा। _ "समाधान" _ आपने हल करने के लिए लिंक किया ** ** मेरे लिए कुछ भी नहीं। लेकिन वैसे भी धन्यवाद, अब मैं अटक गया हूँ। इसके अलावा, मुझे ** संकेतों का उपयोग करने के लिए ** QObject की आवश्यकता है। –