[Qt-interest] How to use QEvent::registerEventType properly
Brian McKinnon
bpmckinnon.qt at gmail.com
Tue Dec 14 15:39:45 CET 2010
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101214/de924fec/attachment.html
More information about the Qt-interest-old
mailing list