zhonghua

C++博客 首页 新随笔 联系 聚合 管理
  72 Posts :: 1 Stories :: 4 Comments :: 0 Trackbacks
I'm building my own custom event and I want to just put this out there to
see if anyone is offended by the way I use the registerEventType function
(since I can't find any specific info on how to use it).  I think it make
sense... but I've never casted a new value into a predefined enum... and I
fear change.

ShapeAnimationEvent.h:

#ifndef SHAPE_ANIMATION_EVENT_H
#define SHAPE_ANIMATION_EVENT_H

#include <QEvent>
#include <QVariant>

class ShapeAnimationEvent : public QEvent
{
public:
    static const QEvent::Type JUMP_TO_TIME;

    ShapeAnimationEvent(QEvent::Type type, QVariant data);
    QVariant data() const;

private:
    QVariant m_data;

};

#endif

ShapeAnimationEvent.cpp:

#include "ShapeAnimationEvent.h"

const QEvent::Type ShapeAnimationEvent::JUMP_TO_TIME =
(QEvent::Type)QEvent::registerEventType();

ShapeAnimationEvent::ShapeAnimationEvent(QEvent::Type type, QVariant data) :
QEvent(type), m_data(data)
{

}

QVariant ShapeAnimationEvent::data() const
{
    return m_data;
}

Thanks,
Brian!
posted on 2012-03-22 14:38 米米 阅读(945) 评论(0)  编辑 收藏 引用 所属分类: qt

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理