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:

Qt Code:
  1. class ArrowGraphicsItem : public QGraphicsItem
  2. {
  3. public:
  4.  
  5. /**
  6.   * \param the source graphics item for the arrow
  7.   * \param the destination graphics item for the arrow, by default it is ZERO
  8.   */
  9. ArrowGraphicsItem(QGraphicsItem *sourceItem,
  10. QGraphicsItem *destinationItem = 0);
  11.  
  12. ~ArrowGraphicsItem();
  13.  
  14. enum { Type = UserType + UserTypesArrowGraphicsItem };
  15.  
  16. /**
  17.   * Retruns the type of this class.Necessary for all QGraphicsItem subclasses
  18.   * \return The type of this class
  19.   */
  20. int type() const;
  21.  
  22. /**
  23.   * The bounding rect for the arrow graphics item
  24.   * \return The bounding rect
  25.   */
  26. QRectF boundingRect() const;
  27.  
  28. ................................................................
  29.  
  30. ................................................................
  31.  
  32. protected:
  33.  
  34. virtual QPainterPath shape() const = 0;
  35.  
  36. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
To copy to clipboard, switch view to plain text mode 


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