Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/164.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++ 没有类型的Q_对象_C++_Qt - Fatal编程技术网

C++ 没有类型的Q_对象

C++ 没有类型的Q_对象,c++,qt,C++,Qt,我收到的错误是: g++-c-g-I/usr/lib/qt-3.3/include TCPEchoServer.cpp 产品:h:22:错误:ISO C++禁止声明“qyObjor”,没有类型 Product.h:24:error:expected-;在无效之前 make:**[TCPEchoServer.o]错误1 我使用的是Qt3.3。 我错过了什么。。。?T______ #include <string> #include <qtimer.h> #include "

我收到的错误是:

g++-c-g-I/usr/lib/qt-3.3/include TCPEchoServer.cpp
产品:h:22:错误:ISO C++禁止声明“qyObjor”,没有类型
Product.h:24:error:expected-;在无效之前 make:**[TCPEchoServer.o]错误1

我使用的是Qt3.3。 我错过了什么。。。?T______

#include <string>
#include <qtimer.h>
#include "HandleTCPClient.h"
#ifndef PRODUCT_H
#define PRODUCT_H
#include <qobject.h>
#include <qgl.h>

class Handler;

//Define ourselves a product class
class Product
    {

        Q_Object

        void startTimer();

    public:
        Product();

        string seller, itemName, description, highestBidder;
        double price, min, buyingPrice, currentBid;
        int time;
        bool isSold;
        Handler *handler;

        void setHandler(Handler *h);

    public slots:
        void setProductToSold();

    };

#endif
#包括
#包括
#包括“HandleTCPClient.h”
#ifndef产品
#定义产品
#包括
#包括
类处理程序;
//定义我们自己的产品类
类产品
{
Q_对象
void startTimer();
公众:
产品();
字符串卖方、项目名称、说明、最高投标人;
双倍价格、最低价格、买入价格、当前出价;
整数时间;
布尔·伊索尔德;
处理者*处理者;
void setHandler(Handler*h);
公众时段:
void setProductToSold();
};
#恩迪夫

您缺少宏的正确大小写,它应该是
Q_OBJECT
您缺少宏的正确大小写,它应该是
Q_OBJECT
,并且QObject应该以某种方式从类继承
QObject


QT3不是这样吗?

并且,QObject应该以某种方式从类
QObject
继承


QT3不是这样吗?

有些吹毛求疵。。。为什么部分但不是全部的代码是ifdefed?另外,您可能需要一个更具体的ifdef。此外,您还以随机顺序将包含项组合在一起。我通常发现将标准头放在一起很有帮助,然后将Qt头放在一起,最后将本地头放在一起。通过这种方式,我可以一目了然地看到使用了什么Qt对象,例如,一些挑剔的地方。。。为什么部分但不是全部的代码是ifdefed?另外,您可能需要一个更具体的ifdef。此外,您还以随机顺序将包含项组合在一起。我通常发现将标准头放在一起很有帮助,然后将Qt头放在一起,最后将本地头放在一起。例如,通过这种方式,我可以一目了然地看到使用了哪些Qt对象。