• 5245阅读
  • 1回复

Q_ENUMS()编译错误 [复制链接]

上一主题 下一主题
离线mpfishere
 
只看楼主 倒序阅读 楼主  发表于: 2011-12-12
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<Type>(registerEventType());
  return EventType;
}
private:
AAction m_action;
QString m_device;
};

请问是因为QT版本的原因不认识Q_ENUMS吗?为什么会出现这种错误呢?谢谢大侠!
离线wxj120bw

只看该作者 1楼 发表于: 2011-12-12
回 楼主(mpfishere) 的帖子
你不该问Q_ENUMS 应该问AAction 下面是qt手册的说明 有例子看下吧
http://doc.qt.nokia.com/latest/qobject.html#Q_ENUMS
快速回复
限100 字节
 
上一个 下一个