sajis997
24th January 2012, 16:12
Hello forum,
I would like to discuss some design issues which may not related directly to Qt, but in some way it is because i am using the graphics view network to get around with this.
I have a class ArrowGraphicsItem (Subclass of QGraphicsItem) as follows:
class ArrowGraphicsItem : public QGraphicsItem
{
public:
/**
* \param the source graphics item for the arrow
* \param the destination graphics item for the arrow, by default it is ZERO
*/
ArrowGraphicsItem(QGraphicsItem *sourceItem,
QGraphicsItem *destinationItem = 0);
~ArrowGraphicsItem();
enum { Type = UserType + UserTypesArrowGraphicsItem };
/**
* Retruns the type of this class.Necessary for all QGraphicsItem subclasses
* \return The type of this class
*/
int type() const;
/**
* The bounding rect for the arrow graphics item
* \return The bounding rect
*/
QRectF boundingRect() const;
.................................................. ..............
.................................................. ..............
protected:
virtual QPainterPath shape() const = 0;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
I have several subclasses which only over-rides the shape() function in their respective subclasses and paint functional definition is always grabbed from default implementation in the ArrowGraphicsItem.
Is that a good design technique ?
Regards
Sajjad
I would like to discuss some design issues which may not related directly to Qt, but in some way it is because i am using the graphics view network to get around with this.
I have a class ArrowGraphicsItem (Subclass of QGraphicsItem) as follows:
class ArrowGraphicsItem : public QGraphicsItem
{
public:
/**
* \param the source graphics item for the arrow
* \param the destination graphics item for the arrow, by default it is ZERO
*/
ArrowGraphicsItem(QGraphicsItem *sourceItem,
QGraphicsItem *destinationItem = 0);
~ArrowGraphicsItem();
enum { Type = UserType + UserTypesArrowGraphicsItem };
/**
* Retruns the type of this class.Necessary for all QGraphicsItem subclasses
* \return The type of this class
*/
int type() const;
/**
* The bounding rect for the arrow graphics item
* \return The bounding rect
*/
QRectF boundingRect() const;
.................................................. ..............
.................................................. ..............
protected:
virtual QPainterPath shape() const = 0;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
I have several subclasses which only over-rides the shape() function in their respective subclasses and paint functional definition is always grabbed from default implementation in the ArrowGraphicsItem.
Is that a good design technique ?
Regards
Sajjad