Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 需要一些关于剖析Qt编译错误的建议吗_C++_Qt_Qml - Fatal编程技术网

C++ 需要一些关于剖析Qt编译错误的建议吗

C++ 需要一些关于剖析Qt编译错误的建议吗,c++,qt,qml,C++,Qt,Qml,我对Qt的Q\u MOC\u OUTPUT\u REVISION自动生成的代码有一些问题 基本上,当我点击构建时,我会得到下面的错误。我不完全确定这一切意味着什么,在过去的一个小时里,我一直在忙着试图弄清楚这意味着什么,但我希望能得到一个更明智的解释,说明这些错误的含义,以及我如何着手消除它们 class Product: public QObject { Q_OBJECT Q_PROPERTY(QString _productid READ _productid WRITE _

我对Qt的
Q\u MOC\u OUTPUT\u 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_属性。 这是基于属性_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

在所有这些上设置属性的名称,Qt宏Q_属性将它们设置为moc_文件中的函数。编译器返回错误,因为他没有找到像QString Product::\u productid()或void Product::\u productid(QString)这样的函数


宏Q_属性的详细信息和更多示例:

首先要问的是:您是否包含了
?对于来自MSVC的人,它类似于DeCuScript的属性编译器特性——除了它在所有C++编译器上都能工作,只要你把你的属性的声明放在另一个文件中并包含在其中,它就可以使MOC阻塞它,同时,如果你将这些函数从一个模块移到另一个模块,那么确保你清除所有的/重建所有的。(一个.cpp文件到另一个文件通常是这样的)并避免在标题中使用.inc文件,因为moc不喜欢这样:-)