Results 1 to 4 of 4

Thread: mouse events

  1. #1
    Join Date
    Mar 2008
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default mouse events

    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):
    Qt Code:
    1. class DiagramItem : public QGraphicsPolygonItem
    2. {
    3. public:
    4. enum { Type = UserType + 15 };
    5. enum DiagramType { Step, Conditional, StartEnd, Io };
    6.  
    7. DiagramItem(DiagramType diagramType, QMenu *contextMenu,
    8. QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
    9.  
    10. void removeArrow(Arrow *arrow);
    11. void removeArrows();
    12. DiagramType diagramType() const
    13. { return myDiagramType; }
    14. QPolygonF polygon() const
    15. { return myPolygon; }
    16. void addArrow(Arrow *arrow);
    17. QPixmap image() const;
    18. int type() const
    19. { return Type;}
    20.  
    21. protected:
    22. void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
    23. QVariant itemChange(GraphicsItemChange change, const QVariant &value);
    24.  
    25. private:
    26. DiagramType myDiagramType;
    27. QPolygonF myPolygon;
    28. QMenu *myContextMenu;
    29. QList<Arrow *> arrows;
    30. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mouse events

    Base implementation of mouse events in QGraphicsItem handles that. And also both the view and the scene can handle events for items.

  3. #3
    Join Date
    Mar 2008
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: mouse events

    Quote Originally Posted by wysota View Post
    Base implementation of mouse events in QGraphicsItem handles that. And also both the view and the scene can handle events for items.
    OK,base class handles if the child didn't implemented it but what is done when the event is handled? shouldn't the DiagramItem class implement it to do a custom job?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mouse events

    If you want to change the original behaviour, then of course, yes.

Similar Threads

  1. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 18:44
  2. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 16:55
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.