[英]Need some advice on dissecting Qt compile error
我對Qt的Q_MOC_OUTPUT_REVISION
自動生成的代碼有一些Q_MOC_OUTPUT_REVISION
。
本質上,當我單擊構建時,出現以下錯誤。 我並不完全確定這意味着什么,並且在過去一個小時中我一直在忙於弄清楚這意味着什么,但是我希望對這些錯誤的含義以及如何解決這些錯誤做出更明智的解釋。
class Product: public QObject
{
Q_OBJECT
Q_PROPERTY(QString _productid READ _productid WRITE _productid)
Q_PROPERTY(QString _productcategoryid READ _productcategoryid WRITE _productcategoryid)
Q_PROPERTY(QString _name READ _name WRITE _name)
Q_PROPERTY(Productcontent * contents READ contents WRITE contents)//dynamic allocation of space for contents
Q_PROPERTY(QString _productimagepath READ _productimagepath WRITE _productimagepath)
Q_PROPERTY(QString _producticonpath READ _producticonpath WRITE _producticonpath )
Q_PROPERTY(QString _productPrice READ _productPrice WRITE _productPrice )
//since this does not change for each product, no need resending it each time
public:
static const string _xmldocpath;
static const string rootitemname;
static const string tagname;
QString _productid;
QString _name;
QString _productcategoryid;
QString _productimagepath;
QString _producticonpath;
QString _productPrice;
Product();
// const std::string &getfilepath();
// const std::string &getproducttagname();
// bool UpdateProductData(string id);
Q_INVOKABLE int FindProductByID(QString id);
~Product();
public slots:
signals:
};
出現以下錯誤。 我不知道該如何解剖這個。 任何幫助將不勝感激。
debug\moc_product.cpp: In member function 'virtual int Productcontent::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_product.cpp:77: error: no match for call to '(QString) ()'
debug\moc_product.cpp:78: error: no match for call to '(QString) ()'
debug\moc_product.cpp:84: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:85: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp: In member function 'virtual int Product::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_product.cpp:179: error: no match for call to '(QString) ()'
debug\moc_product.cpp:180: error: no match for call to '(QString) ()'
debug\moc_product.cpp:181: error: no match for call to '(QString) ()'
debug\moc_product.cpp:182: error: 'contents' was not declared in this scope
debug\moc_product.cpp:183: error: no match for call to '(QString) ()'
debug\moc_product.cpp:184: error: no match for call to '(QString) ()'
debug\moc_product.cpp:185: error: no match for call to '(QString) ()'
debug\moc_product.cpp:191: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:192: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:193: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:194: error: 'contents' was not declared in this scope
debug\moc_product.cpp:195: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:196: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:197: error: no match for call to '(QString) (QString&)'
mingw32-make.exe[1]: Leaving directory `C:/Users/minel/QMLUIProject_One-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug'
mingw32-make.exe[1]: *** [debug/moc_product.o] Error 1
mingw32-make.exe: *** [debug] Error 2
17:45:04: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project QMLUIProject_One (target: Desktop)
When executing build step 'Make'
在我看來,您現在不怎么使用Q_PROPERTY。 這是基於您的_productid屬性代碼的示例,我沒有添加不必要的內容:
class Product: public QObject
{
Q_OBJECT
Q_PROPERTY(QString _productid READ _getProductid WRITE _setProductid)
public:
QString _productid;
QString _getProductid() const {return _productid;}
void _setProductid(QString product){_productid = product;}
};
對於READ設置返回_productid值的函數的名稱。
對於WRITE,設置_productid的功能設置值的名稱。
所有這些都設置了Your屬性的名稱,而Qt宏Q_PROPERTY將它們設置為moc_file中的函數。 編譯器返回錯誤,因為他沒有找到類似QString Product :: _ productid()或無效Product :: _ productid(QString)之類的函數。
宏Q_PROPERTY的詳細信息和更多示例: http : //developer.qt.nokia.com/doc/qt-4.8/properties.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.