[Solved]Problem compiling with Q_PROPERTY

  • I am building a shared library for a major project at work, but I am running into a wall. Basically I am trying to create a class that inherits from Q_Object and uses Q_PROPERTY which is how all the fields will be accessed. I am getting strange errors in the moc_* files that qt generates that say that my functions don't exist even though they do. Heres the code and the errors.

    @#ifndef PROJECT_H
    #define PROJECT_H

    #include <QDate>
    #include <QUuid>
    #include <QObject>
    #include <QLinkedList>
    #include <QSqlQuery>
    #include <QObject>
    #include "DAL_global.h"
    #include "dal.h"

    class DALSHARED_EXPORT Project : public QObject
    Q_PROPERTY(int id READ getID WRITE setID)
    Q_PROPERTY(QString name READ getName WRITE setName)
    Q_PROPERTY(QString shortName READ getShortName WRITE setShortName)
    Q_PROPERTY(QDate startDate READ getStartDate WRITE setStartDate)
    Q_PROPERTY(QDate endName READ getEndDate WRITE setEndDate)
    Q_PROPERTY(int statusID READ getStatusID WRITE setStatusID)
    Q_PROPERTY(int clientID READ getClientID WRITE setClientID)
    Q_PROPERTY(QDate dateCreated READ getDateCreated WRITE setDateCreated)
    Q_PROPERTY(QString path READ getPath WRITE setPath)
    Q_PROPERTY(bool audio READ getAudio WRITE setAudio)
    Q_PROPERTY(int clientContactID READ getClientContactID WRITE setClientContactID)
    Q_PROPERTY(QString imageURL READ getimageURL WRITE setimageURL)
    Q_PROPERTY(double fps READ getFps WRITE setFps)
    Q_PROPERTY(QUuid rssGuid READ getRssGuid WRITE setRssGuid)
    Q_PROPERTY(QString frameRatio READ getFrameRatio WRITE setFrameRatio)
    Q_PROPERTY(double pixelAspect READ getPixelAspect WRITE setPixelAspect)
    Q_PROPERTY(double deviceAspect READ getDeviceAspect WRITE setDeviceAspect)
    Q_PROPERTY(QString resolution READ getResolution WRITE setResolution)
    Q_PROPERTY(int deliveryTypeID READ getDeliveryTypeID WRITE setDeliveryTypeID)
    Q_PROPERTY(QString textureFormat READ getTextureFormat WRITE setTextureFormat)
    Q_PROPERTY(QString deliveryNotes READ getDeliveryNotes WRITE setDeliveryNotes)
    Q_PROPERTY(bool fieldEnable READ getFieldEnable WRITE setFieldEnable)
    Q_PROPERTY(bool fieldInterleave READ getFieldInterleave WRITE setFieldInterleave)
    Q_PROPERTY(int fieldOrder READ getFieldOrder WRITE setFieldOrder)
    Q_PROPERTY(int framePadding READ getFramePadding WRITE setFramePadding)
    Q_PROPERTY(QString framesDirectory READ getFrameDirectory WRITE setFrameDirectory)

    Q_PROPERTY(QString projectStatusName READ getSatusName WRITE setStatusName)
    Q_PROPERTY(QString clientName READ getClientName WRITE setClientName)
    Q_PROPERTY(QString clientContactName READ getClientContactName WRITE setClientContactName)
    Q_PROPERTY(QString clientContactTitle READ getClientContactTitle WRITE setClientContactTitle)
    Q_PROPERTY(QString deliveryTypeName READ getDeliveryTypeName WRITE setDeliveryTypeName)

    explicit Project(QObject *parent = 0);
    Project(int, QString, QString, QDate, QDate, int, int, QDate, QString, bool, int, QString, double, QUuid,
    QString, double, double, QString, int, QString, QString, bool, bool, int, int, QString,
    QString, QString, QString, QString, QString);

    static QLinkedList<Project>* SelectProjects(bool);


    public slots:

    // property functions
    int getID() const;
    void setID(int);

    QString getName() const;
    void setName(const QString&);
    QString getShortName() const;
    void setShortName(const QString&);
    QDate getStartDate() const;
    void setStartDate(const QDate&);
    QDate getEndDate() const;
    void setEndDate(const QDate&);
    int getStatusID() const;
    void setStatusID(int);
    int getClientID() const;
    void setClientID(int);
    QString getImageURL() const;
    void setImageURL(const QString&);
    double getFps() const;
    void setFps(double);
    QUuid getRssGuid() const;
    void setRssGuid(QUuid);
    QString getFrameRatio() const;
    void setFrameRatio(const QString&);
    double getPixelAspect() const;
    void setPixelAspect(double);
    double getDeviceAspect() const;
    void setDeviceAspect(double);
    QString getResolution() const;
    void setResolution(QString);
    int getDeliveryTypeID() const;
    void setDeliveryTypeID(int);
    QString getTextureFormat() const;
    void setTextureFormat(const QString&);
    QString getDeliveryNotes() const;
    void setDeliveryNotes(const QString&);
    bool getFieldEnable() const;
    void setFieldEnable(bool);
    bool getFieldInterleave() const;
    void setFieldInterleave(bool);
    int getFieldOrder() const;
    void setFieldOrder(int);
    int getFramePadding() const;
    void setFramePadding(int);
    QString getFramesDirectory() const;
    void setFramesDirectory(const QString&);
    // table values
    int _id;
    QString _name;
    QString _shortName;
    QDate _startDate;
    QDate _endDate;
    int _statusID;
    int _clientID;
    QDate _dateCreated;
    QString _path;
    bool _audio;
    int _clientContactID;
    QString _imageURL;
    double _fps;
    QUuid _rssGuid;
    QString _frameRatio;
    double _pixelAspect;
    double _deviceAspect;
    QString _resolution;
    int _deliveryTypeID;
    QString _textureFormat;
    QString _deliveryNotes;
    bool _fieldEnable;
    bool _fieldInterleave;
    int _fieldOrder;
    int _framePadding;
    QString _framesDirectory;
    // not in table
    QString _statusName;
    QString _clientName;
    QString _clientContactName;
    QString _clientContactTitle;
    QString _deliveryTypeName;


    #endif // PROJECT_H

  • Implementation
    @#include "project.h"

    Project::Project(QObject *parent) :
    _id = 0;
    Project::Project(int id, QString name, QString shortName, QDate startDate, QDate endDate, int statusID,
    int clientID, QDate dateCreated, QString path, bool audio, int clientContactID,
    QString imageURL, double fps, QUuid rssGuid, QString frameRatio, double pixelAspect,
    double deviceAspect, QString resolution, int deliveryTypeID, QString textureFormat,
    QString deliveryNotes, bool fieldEnable, bool fieldInterleave, int fieldOrder,
    int framePadding, QString framesDirectory, QString statusName, QString clientName,
    QString clientContactName, QString clientContactTitle, QString deliveryTypeName){
    _id = id;
    _name = name;
    _shortName = shortName;
    _startDate = startDate;
    _endDate = endDate;
    _statusID = statusID;
    _clientID = clientID;
    _dateCreated = dateCreated;
    _path = path;
    _audio = audio;
    _clientContactID = clientContactID;
    _imageURL = imageURL;
    _fps = fps;
    _rssGuid = rssGuid;
    _frameRatio = frameRatio;
    _pixelAspect = pixelAspect;
    _deviceAspect = deviceAspect;
    _resolution = resolution;
    _deliveryTypeID = deliveryTypeID;
    _textureFormat = textureFormat;
    _deliveryNotes = deliveryNotes;
    _fieldEnable = fieldEnable;
    _fieldInterleave = fieldInterleave;
    _fieldOrder = fieldOrder;
    _framePadding = framePadding;
    _framesDirectory = framesDirectory;
    _statusName = statusName;
    _clientName = clientName;
    _clientContactName = clientContactName;
    _clientContactTitle = clientContactTitle;
    _deliveryTypeName = deliveryTypeName;

    //property functions
    int Project::getID() const{
    return _id;

    void Project::setID(int val){
    _id = val;

    QString Project::getName() const{
    return _name;

    void Project::setName(const QString& val){
    _name = val;

    QString Project::getShortName() const{
    return _shortName;
    void Project::setShortName(const QString& val){
    _shortName = val;

    QDate Project::getStartDate() const {
    return _startDate;

    void Project::setStartDate(const QDate& val) {
    _startDate = val;

    QDate Project::getEndDate() const {
    return _endDate;

    void Project::setEndDate(const QDate& val){
    _endDate = val;

    int Project::getStatusID() const {
    return _statusID;

    void Project::setStatusID(int val) {
    _statusID = val;

    int Project::getClientID() const {
    return _clientID;

    void Project::setClientID(int val){
    _clientID = val;

    QString Project::getImageURL() const{
    return _imageURL;

    void Project::setImageURL(const QString& val){
    _imageURL = val;

    double Project::getFps() const{
    return _fps;

    void Project::setFps(double val){
    _fps = val;

    QUuid Project::getRssGuid() const{
    return _rssGuid;

    void Project::setRssGuid(QUuid val){
    _rssGuid = val;

    QString Project::getFrameRatio() const{
    return _frameRatio;

    void Project::setFrameRatio(const QString& val){
    _frameRatio = val;

    double Project::getPixelAspect() const{
    return _pixelAspect;

    void Project::setPixelAspect(double val){
    _pixelAspect = val;

    double Project::getDeviceAspect() const {
    return _deviceAspect;

    void Project::setDeviceAspect(double val){
    _deviceAspect = val;

    QString Project::getResolution() const{
    return _resolution;

    void Project::setResolution(QString val){
    _resolution = val;

    int Project::getDeliveryTypeID() const{
    return _deliveryTypeID;

    void Project::setDeliveryTypeID(int val){
    _deliveryTypeID = val;

    QString Project::getTextureFormat() const{
    return _textureFormat;

    void Project::setTextureFormat(const QString& val){
    _textureFormat = val;

    QString Project::getDeliveryNotes() const{
    return _deliveryNotes;

    void Project::setDeliveryNotes(const QString& val){
    _deliveryNotes = val;

    bool Project::getFieldEnable() const{
    return _fieldEnable;

    void Project::setFieldEnable(bool val){
    _fieldEnable = val;

    bool Project::getFieldInterleave() const {
    return _fieldInterleave;

    void Project::setFieldInterleave(bool val){
    _fieldInterleave = val;

    int Project::getFieldOrder() const{
    return _fieldOrder;

    void Project::setFieldOrder(int val){
    _fieldOrder = val;

    int Project::getFramePadding() const{
    return _framePadding;

    void Project::setFramePadding(int val){
    _framePadding = val;

    QString Project::getFramesDirectory() const{
    return _framesDirectory;

    void Project::setFramesDirectory(const QString& val){
    _framesDirectory = val;

    // select all or only the active projects
    QLinkedList<Project>* Project::SelectProjects(bool activeOnly){
    QLinkedList<Project>* llProjects = new QLinkedList<Project>();
    QSqlDatabase db;
    QSqlQuery query;
    return llProjects;

  • Errors:

    Running build steps for project DAL...
    Configuration unchanged, skipping qmake step.
    Starting: "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `D:/Development/Qt/DAL-build-desktop'

    D:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug

    mingw32-make[1]: Entering directory `D:/Development/Qt/DAL-build-desktop'

    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DDAL_LIBRARY -DQT_DLL -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"......\Qt\2010.05\qt\include\QtCore" -I"......\Qt\2010.05\qt\include\QtSql" -I"......\Qt\2010.05\qt\include" -I"......\Qt\2010.05\qt\include\ActiveQt" -I"debug" -I"..\DAL" -I"." -I"......\Qt\2010.05\qt\mkspecs\win32-g++" -o debug\project.o ..\DAL\project.cpp

    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DDAL_LIBRARY -DQT_DLL -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"......\Qt\2010.05\qt\include\QtCore" -I"......\Qt\2010.05\qt\include\QtSql" -I"......\Qt\2010.05\qt\include" -I"......\Qt\2010.05\qt\include\ActiveQt" -I"debug" -I"..\DAL" -I"." -I"......\Qt\2010.05\qt\mkspecs\win32-g++" -o debug\moc_project.o debug\moc_project.cpp

    mingw32-make[1]: Leaving directory `D:/Development/Qt/DAL-build-desktop'

    mingw32-make: Leaving directory `D:/Development/Qt/DAL-build-desktop'

    debug\moc_project.cpp: In member function 'virtual int Project::qt_metacall(QMetaObject::Call, int, void**)':

    debug\moc_project.cpp:122: error: 'getDateCreated' was not declared in this scope

    debug\moc_project.cpp:123: error: 'getPath' was not declared in this scope

    debug\moc_project.cpp:124: error: 'getAudio' was not declared in this scope

    debug\moc_project.cpp:125: error: 'getClientContactID' was not declared in this scope

    debug\moc_project.cpp:126: error: 'getimageURL' was not declared in this scope

    debug\moc_project.cpp:140: error: 'getFrameDirectory' was not declared in this scope

    debug\moc_project.cpp:141: error: 'getSatusName' was not declared in this scope

    debug\moc_project.cpp:142: error: 'getClientName' was not declared in this scope

    debug\moc_project.cpp:143: error: 'getClientContactName' was not declared in this scope

    debug\moc_project.cpp:144: error: 'getClientContactTitle' was not declared in this scope

    debug\moc_project.cpp:145: error: 'getDeliveryTypeName' was not declared in this scope

    debug\moc_project.cpp:158: error: 'setDateCreated' was not declared in this scope

    debug\moc_project.cpp:159: error: 'setPath' was not declared in this scope

    debug\moc_project.cpp:160: error: 'setAudio' was not declared in this scope

    debug\moc_project.cpp:161: error: 'setClientContactID' was not declared in this scope

    debug\moc_project.cpp:162: error: 'setimageURL' was not declared in this scope

    debug\moc_project.cpp:176: error: 'setFrameDirectory' was not declared in this scope

    debug\moc_project.cpp:177: error: 'setStatusName' was not declared in this scope

    debug\moc_project.cpp:178: error: 'setClientName' was not declared in this scope

    debug\moc_project.cpp:179: error: 'setClientContactName' was not declared in this scope

    debug\moc_project.cpp:180: error: 'setClientContactTitle' was not declared in this scope

    debug\moc_project.cpp:181: error: 'setDeliveryTypeName' was not declared in this scope

    mingw32-make[1]: *** [debug/moc_project.o] Error 1

    mingw32-make: *** [debug] Error 2

    The process "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project DAL (target: Desktop)
    When executing build step 'Make'

  • O man I'm embarrassed, I accidentally deleted those functions, please disregard this.

Log in to reply