0
任何人都可以向我解釋這個錯誤嗎?它好像它是與MOC發生的錯誤:Qt 4.7找不到符號錯誤
Undefined symbols:
make: Leaving directory `/Users/Dylan/Documents/programming/qt/Clock-build-desktop'
"ClockDelegate::ClockDelegate(QObject*)", referenced from:
AnalogClockDelegate::AnalogClockDelegate(QObject*)in AnalogClockDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [Clock.app/Contents/MacOS/Clock] Error 1
The process "/usr/bin/make" exited with code 2.
Error while building project Clock (target: Desktop)
When executing build step 'Make'
ClockDelegate:
#ifndef CLOCKDELEGATE_H
#define CLOCKDELEGATE_H
#include <QObject>
class QTime;
class QWidget;
class ClockDelegate : public QObject
{
Q_OBJECT
public:
explicit ClockDelegate(QObject *parent);
virtual void paintClock(QWidget *, QTime *) = 0;
};
#endif // CLOCKDELEGATE_H
AnalogClockDelegate:
#ifndef ANALOGCLOCKDELEGATE_H
#define ANALOGCLOCKDELEGATE_H
#include <QColor>
#include <QPoint>
#include "ClockDelegate.h"
class QWidget;
class AnalogClockDelegate : public ClockDelegate
{
Q_OBJECT
public:
explicit AnalogClockDelegate(QObject *parent);
void paintClock(QWidget *, QTime *);
private:
void setupClockHands();
void drawClockSurface(QWidget *clockView, QTime *);
void drawHourComponent(QWidget *clockView);
void drawMinuteComponent(QWidget *clockView, QTime *);
void drawSecondComponent(QWidget *clockView, QTime *);
QPoint m_center;
QPoint m_hourHand[3];
QPoint m_minuteHand[3];
QPoint m_secondHand[2];
QColor m_hourColor;
QColor m_minuteColor;
QColor m_secondColor;
QColor m_clockFaceColor;
};
#endif // ANALOGCLOCKDELEGATE_H
這就是問題所在。一小時後,我試圖消除這個錯誤,我正瀕臨脫髮。謝謝。 – dtg
另一種情況是,您從中派生的對象是在名稱空間中定義的。您可能也需要編寫命名空間。 '公共ns1 :: ns2 :: myClass' ... –
我說得太快了。糾正上述錯誤,我知道得到「符號未找到」的錯誤。看起來moc不喜歡ClockDelegate或AnalogClockDelegate。我將編輯上述內容。 – dtg