Qt : Error when compiling moc files for newly added classes
-
Hi Qt-Experts,
I am a newbie in QT development. I am trying to introduce new position info source class which is a derived class of the QGeoPositionInfoSource. This derived class would be making communication with the GPS device through a customer GPS software. I am having a difficult time in compiling this sample class to do this activity. I keep getting below error when I compile the code
c_qgeopositioninfosource_linux_p.o ../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:48: error: âQGeoPositionInfoSourceLinuxâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:49: error: âQGeoPositionInfoSourceâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:57: error: âQGeoPositionInfoSourceLinuxâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:57: error: non-member function âconst QMetaObject* metaObject()â cannot have cv-qualifier
/usr/include/qt4/QtCore/qobject.h: In function âconst QMetaObject* metaObject()â:
/usr/include/qt4/QtCore/qobject.h:296: error: âQScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptrâ is protected
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:59: error: within this context
/usr/include/qt4/QtCore/qobject.h:296: error: invalid use of non-static data member âQObject::d_ptrâ
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:59: error: from this location
/usr/include/qt4/QtCore/qobject.h:296: error: âQScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptrâ is protected
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:59: error: within this context
/usr/include/qt4/QtCore/qobject.h:296: error: invalid use of non-static data member âQObject::d_ptrâ
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:59: error: from this location
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp: At global scope:
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:62: error: âQGeoPositionInfoSourceLinuxâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp: In function âvoid* qt_metacast(const char*)â:
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: expected type-specifier before âQGeoPositionInfoSourceLinuxâ
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: expected â>â before âQGeoPositionInfoSourceLinuxâ
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: expected â(â before âQGeoPositionInfoSourceLinuxâ
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: âQGeoPositionInfoSourceLinuxâ was not declared in this scope
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: expected primary-expression before â>â token
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: invalid use of âthisâ in non-member function
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:66: error: expected â)â before â;â token
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:67: error: âQGeoPositionInfoSourceâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp: At global scope:
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:70: error: âQGeoPositionInfoSourceLinuxâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp: In function âint qt_metacall(QMetaObject::Call, int, void**)â:
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:72: error: âQGeoPositionInfoSourceâ has not been declared
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:77: error: âstartUpdatesâ was not declared in this scope
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:78: error: âstopUpdatesâ was not declared in this scope
../../build/Debug/QtLocation/moc/moc_qgeopositioninfosource_linux_p.cpp:79: error: ârequestUpdateâ was not declared in this scopeMy qgeopositioninfosource_linux_p.h is as below:
@
#ifndef QGEOPOSITIONINFOSOURCELINUX_H
#define QGEOPOSITIONINFOSOURCELINUX_H
#include "qgeopositioninfosource.h"QTM_BEGIN_NAMESPACE
class QGeoPositionInfoSourceLinux : public QGeoPositionInfoSource
{
Q_OBJECTpublic:
QGeoPositionInfoSourceLinux(QObject *parent = 0);
virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
virtual PositioningMethods supportedPositioningMethods() const;
virtual int minimumUpdateInterval() const;
public Q_SLOTS:
void startUpdates();
void stopUpdates();
void requestUpdate(int timeout = 5000);
};QTM_END_NAMESPACE
#endif
@
I am just unable to resolve this error that is reported when compiling the moc file. Any help from QT experts to resolve this error is highly appreciated.Sorry if the post is repeated in same forum.
BR,
-RaghuEdit: please use @ tags around code sections; Andre
-
Could you post .pro file?
-
Also, sometimes, it helps to manually run qmake on your project again.
-
Thanks for your reply.
I have just added PRIVATE_HEADERS and SOURCES in "location.pro" which is available in QtMobility source "qt-mobility-opensource-src-1.2.0, I want the class to be part of libQtLocation.so and I am compiling this on Linux
SOURCES += qgeopositioninfosource_linux.cpp
PRIVATE_HEADERS += qgeopositioninfosource_linux_p.h
Not able to post entire .pro file because of the size limitation.
-
I did run qmake several times but did not help . I first want to know the root cause of this error.