Qt World Summit: Register Today!


  • @
    void MySquare::mousePressEvent(QGraphicsSceneMouseEvent * event)

    In this code , MySquare is a subclass of QGraphicsItem. I need to know why after handling mousePressEvent() in subclass it is passed to Base Class.......It works even without that line, then why it is passed as a standard coding procedure.

    [edit: added missing coding tags @ SGaist]

  • Lifetime Qt Champion


    Because sometimes base class implementation do something and it should still be done. Whether you need to call the base class implementation and when you need to call it depends on what it does, what you do and how you do it.

  • Thanks for the reply.... Can u give me a situation where it is required so i get a clear picture.....

  • Lifetime Qt Champion

    An example is the data method from QIdentityProxyModel. You generally reimplement it to handle your special cases and for the rest you return the original implementation value.

Log in to reply