in the documentation there's a sample that demonstrates Graphics View Framework. The class DiagramItem inherits QGraphicsPolygonItem but it doesn't override the mouse events, so how can it answer to the mouse events?
here's the code:(copied from the QT Documentation):
{
public:
enum { Type = UserType + 15 };
enum DiagramType { Step, Conditional, StartEnd, Io };
DiagramItem
(DiagramType diagramType,
QMenu *contextMenu,
void removeArrow(Arrow *arrow);
void removeArrows();
DiagramType diagramType() const
{ return myDiagramType; }
{ return myPolygon; }
void addArrow(Arrow *arrow);
int type() const
{ return Type;}
protected:
private:
DiagramType myDiagramType;
QList<Arrow *> arrows;
};
class DiagramItem : public QGraphicsPolygonItem
{
public:
enum { Type = UserType + 15 };
enum DiagramType { Step, Conditional, StartEnd, Io };
DiagramItem(DiagramType diagramType, QMenu *contextMenu,
QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
void removeArrow(Arrow *arrow);
void removeArrows();
DiagramType diagramType() const
{ return myDiagramType; }
QPolygonF polygon() const
{ return myPolygon; }
void addArrow(Arrow *arrow);
QPixmap image() const;
int type() const
{ return Type;}
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
DiagramType myDiagramType;
QPolygonF myPolygon;
QMenu *myContextMenu;
QList<Arrow *> arrows;
};
To copy to clipboard, switch view to plain text mode
Bookmarks