标题:Q_ENUMS()编译错误
作者:mpfishere
日期:2011-12-12 17:45
内容:
1>d:\我的文档\visual studio 2005\projects\test_qdbus\test_qdbus\qdevicechangeevent.h(29) : error C2061: syntax error : identifier 'AAction'
1>d:\我的文档\visual studio 2005\projects\test_qdbus\test_qdbus\qdevicechangeevent.h(31) : error C2143: syntax error : missing ';' before 'public'
1>d:\我的文档\visual studio 2005\projects\test_qdbus\test_qdbus\qdevicechangeevent.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\我的文档\visual studio 2005\projects\test_qdbus\test_qdbus\qdevicechangeevent.h(31) : warning C4183: 'Q_ENUMS': missing return type; assumed to be a member function returning 'int'
我的QT是4.5.0版本的,在继承QEvent类时代码如下:
class Q_DLL_EXPORT QDeviceChangeEvent : public QEvent
{
Q_ENUMS(AAction)
public:
enum AAction { Add, Remove, Change};
//static const Type EventType; //VC link error
explicit QDeviceChangeEvent(AAction action, const QString& device);
AAction action() const {return m_action;}
QString device() const {return m_device;}
static Type registeredType()
{
static Type EventType = static_cast(registerEventType());
return EventType;
}
private:
AAction m_action;
QString m_device;
};
请问是因为QT版本的原因不认识Q_ENUMS吗?为什么会出现这种错误呢?谢谢大侠!
#1 回 楼主(mpfishere) 的帖子 [wxj120bw 12-12 21:49]
你不该问Q_ENUMS 应该问AAction 下面是qt手册的说明 有例子看下吧
http://doc.qt.nokia.com/latest/qobject.html#Q_ENUMS