Results 1 to 3 of 3

Thread: Error when compiling moc files for newly added classes

  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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 scope


    My qgeopositioninfosource_linux_p.h is as below:

    #ifndef QGEOPOSITIONINFOSOURCELINUX_H
    #define QGEOPOSITIONINFOSOURCELINUX_H
    #include "qgeopositioninfosource.h"

    QTM_BEGIN_NAMESPACE

    class QGeoPositionInfoSourceLinux : public QGeoPositionInfoSource
    {
    Q_OBJECT

    public:
    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.

    BR,
    -Raghu

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error when compiling moc files for newly added classes

    Why are you trying to put your class into the Qt Mobility namespace? Did you perhaps intend this:
    Qt Code:
    1. #ifndef QGEOPOSITIONINFOSOURCELINUX_H
    2. #define QGEOPOSITIONINFOSOURCELINUX_H
    3. #include "qgeopositioninfosource.h"
    4.  
    5. QTM_USE_NAMESPACE
    6. // ^^^^^^^^^^^^^^ this
    7.  
    8. class QGeoPositionInfoSourceLinux : public QGeoPositionInfoSource
    9. {
    10. ...
    11. };
    12.  
    13. #endif
    To copy to clipboard, switch view to plain text mode 
    as described here. Is Qt Mobility enabled in your Pro file?

  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Error when compiling moc files for newly added classes

    Yes, I intend to use Qt Mobility namespace. I want the class to be built as part of the QtLocation library.

    Have just added SOURCES and PRIVATE_HEADERS as below in the location.pro file.


    SOURCES += qgeopositioninfosource_linux.cpp
    PRIVATE_HEADERS += qgeopositioninfosource_linux_p.h

Similar Threads

  1. Replies: 14
    Last Post: 2nd August 2011, 12:42
  2. Compiling all classes on every build
    By pan in forum Newbie
    Replies: 0
    Last Post: 16th February 2011, 09:51
  3. Replies: 1
    Last Post: 28th October 2010, 22:36
  4. Compiling .c files using C++ and QT
    By kurt-hardy in forum General Programming
    Replies: 3
    Last Post: 7th September 2010, 18:18
  5. Replies: 1
    Last Post: 25th October 2008, 19:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.