for completeness, here is the InteractiveQGraphicsFrameItem class, which works without problems:
#ifndef INTERACTIVEQGRAPHICSFRAMEITEM_H
#define INTERACTIVEQGRAPHICSFRAMEITEM_H
#include <QSharedData>
#include "GraphicItemsSharedLibrary.h"
#include "AbstractInteractiveQGraphicsItem.h"
class InteractiveQGraphicsFrameItemData;
class GRAPHICITEMS_SHAREDLIB_LIB_EXPORT InteractiveQGraphicsFrameItem : public AbstractInteractiveQGraphicsItem
{
public:
InteractiveQGraphicsFrameItem
(AbstractInteractiveQGraphicsCoordinationItem
* parent
= 0,
QGraphicsScene* scene
= 0);
virtual ~InteractiveQGraphicsFrameItem();
virtual QRectF boundingRect
() const;
virtual void setDrawNewRectOnClickOutOfTheFrame(bool b);
virtual void setFillColor
(const QColor &color
);
virtual void setFrame(const QRectF& rect);
virtual void setFrameColor
(const QColor &color
);
virtual void setHandleFillColor
(const QColor &color
);
virtual void setHandleFrameColor
(const QColor &color
);
virtual void setMaximumHandleSize(double size);
virtual void setOuterFillColor
(const QColor &color
);
protected:
virtual void adjustHandleSize();
virtual void keyPressEvent
(QKeyEvent* event
);
virtual void keyReleaseEvent
(QKeyEvent* event
);
// virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
// virtual void wheelEvent(QGraphicsSceneWheelEvent* event);
virtual void updateHandles();
protected:
QSharedDataPointer<InteractiveQGraphicsFrameItemData> d;
};
#endif // INTERACTIVEQGRAPHICSFRAMEITEM_H
#ifndef INTERACTIVEQGRAPHICSFRAMEITEM_H
#define INTERACTIVEQGRAPHICSFRAMEITEM_H
#include <QSharedData>
#include "GraphicItemsSharedLibrary.h"
#include "AbstractInteractiveQGraphicsItem.h"
class QGraphicsScene;
class QRectF;
class QColor;
class QPainter;
class QStyleOptionGraphicsItem;
class QWidget;
class QGraphicsSceneHoverEvent;
class QGraphicsSceneMouseEvent;
class QKeyEvent;
class QGraphicsSceneWheelEvent;
class InteractiveQGraphicsFrameItemData;
class GRAPHICITEMS_SHAREDLIB_LIB_EXPORT InteractiveQGraphicsFrameItem : public AbstractInteractiveQGraphicsItem
{
public:
InteractiveQGraphicsFrameItem(AbstractInteractiveQGraphicsCoordinationItem* parent = 0, QGraphicsScene* scene = 0);
virtual ~InteractiveQGraphicsFrameItem();
virtual QRectF boundingRect() const;
virtual QRectF getRect();
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual void setDrawNewRectOnClickOutOfTheFrame(bool b);
virtual void setFillColor(const QColor &color);
virtual void setFrame(const QRectF& rect);
virtual void setFrameColor(const QColor &color);
virtual void setHandleFillColor(const QColor &color);
virtual void setHandleFrameColor(const QColor &color);
virtual void setMaximumHandleSize(double size);
virtual void setOuterFillColor(const QColor &color);
protected:
virtual void adjustHandleSize();
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
// virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
// virtual void wheelEvent(QGraphicsSceneWheelEvent* event);
virtual void updateHandles();
protected:
QSharedDataPointer<InteractiveQGraphicsFrameItemData> d;
};
#endif // INTERACTIVEQGRAPHICSFRAMEITEM_H
To copy to clipboard, switch view to plain text mode
#ifndef INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
#define INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
#include <QSharedData>
#include <QRectF>
#include <QPointF>
#include <QVector>
#include <QColor>
class InteractiveQGraphicsFrameItemData
: public QSharedData{
public:
InteractiveQGraphicsFrameItemData();
bool mouseDown;
bool mouseInObject;
bool newSelection;
bool lockAspectRatio;
bool drawNewRectOnClickOutOfTheFrame;
double handleSize;
double maximumHandleSize;
// naming convention for handles
// T top, B bottom, R Right, L left
// 2 letters: a corner
// 1 letter: the handle on the middle of the corresponding side
QRectF TLHandle, TRHandle, BLHandle, BRHandle;
QRectF LHandle, THandle, RHandle, BHandle;
QVector<QRectF*> handles;
};
#endif // INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
#ifndef INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
#define INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
#include <QSharedData>
#include <QRectF>
#include <QPointF>
#include <QVector>
#include <QColor>
class InteractiveQGraphicsFrameItemData : public QSharedData
{
public:
InteractiveQGraphicsFrameItemData();
QRectF frame;
bool mouseDown;
bool mouseInObject;
bool newSelection;
bool lockAspectRatio;
bool drawNewRectOnClickOutOfTheFrame;
double handleSize;
double maximumHandleSize;
QRectF* mouseOverHandle;
QPointF dragStartPoint;
QRectF frameBeforeDrag;
QColor fillColor;
QColor frameColor;
QColor handleFillColor;
QColor handleFrameColor;
QColor outerFillColor;
// naming convention for handles
// T top, B bottom, R Right, L left
// 2 letters: a corner
// 1 letter: the handle on the middle of the corresponding side
QRectF TLHandle, TRHandle, BLHandle, BRHandle;
QRectF LHandle, THandle, RHandle, BHandle;
QVector<QRectF*> handles;
};
#endif // INTERACTIVEQGRAPHICSFRAMEITEMDATA_H
To copy to clipboard, switch view to plain text mode
Now where is the difference to the InteractiveQGraphicsLineItem class, which makes the one compile and the other not?
Bookmarks