summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-09-01 08:06:38 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-09-01 10:10:13 (GMT)
commitc15e07884a29be26f1110e4d54a56da0001e3c53 (patch)
treeb81650fe5652e3fdd4592da73c3a6f3902bed3e1 /demos
parentc78d75db9467af9f5638073f74bed437c24c3584 (diff)
downloadQt-c15e07884a29be26f1110e4d54a56da0001e3c53.zip
Qt-c15e07884a29be26f1110e4d54a56da0001e3c53.tar.gz
Qt-c15e07884a29be26f1110e4d54a56da0001e3c53.tar.bz2
dynamic_cast in the demo was failing to build without rtti
Reviewed-by: Kim Motoyoshi Kalland
Diffstat (limited to 'demos')
-rw-r--r--demos/boxes/qtbox.cpp14
-rw-r--r--demos/boxes/qtbox.h6
2 files changed, 14 insertions, 6 deletions
diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp
index 015bc95..54882fb 100644
--- a/demos/boxes/qtbox.cpp
+++ b/demos/boxes/qtbox.cpp
@@ -122,7 +122,7 @@ void ItemBase::duplicateSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y()));
}
@@ -137,7 +137,7 @@ void ItemBase::deleteSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
delete itemBase;
}
@@ -152,7 +152,7 @@ void ItemBase::growSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size *= 2;
@@ -171,7 +171,7 @@ void ItemBase::shrinkSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size /= 2;
@@ -257,6 +257,12 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
m_size = MIN_ITEM_SIZE;
}
+int ItemBase::type() const
+{
+ return Type;
+}
+
+
bool ItemBase::isInResizeArea(const QPointF &pos)
{
return (-pos.y() < pos.x() - m_size + 9);
diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h
index 6f39b0d..9465911 100644
--- a/demos/boxes/qtbox.h
+++ b/demos/boxes/qtbox.h
@@ -47,10 +47,11 @@
#include <QtGui/qvector3d.h>
#include "glbuffers.h"
-class ItemBase : public QObject, public QGraphicsItem
+class ItemBase : public QGraphicsItem
{
- Q_OBJECT
public:
+ enum { Type = UserType + 1 };
+
ItemBase(int size, int x, int y);
virtual ~ItemBase();
virtual QRectF boundingRect() const;
@@ -64,6 +65,7 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
+ virtual int type() const;
bool isInResizeArea(const QPointF &pos);
static void duplicateSelectedItems(QGraphicsScene *scene);