hi
I need to create an inherited class of QGraphicsItem that implements the mouse click and hover events in it, can anybody give a simple example of how to do this??
thanks.
hi
I need to create an inherited class of QGraphicsItem that implements the mouse click and hover events in it, can anybody give a simple example of how to do this??
thanks.
Simple reimplement the event handlers: QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent() and QGraphicsItem::mouseMoveEvent(), but for the last you have to set the corresponding flag to receive these events.
Here is an example:
Qt Code:
#include <QGraphicsItem> { Q_OBJECT public: // Konstruktor { // initialize } protected: /** * Event: Mousbutton is released ( = Clicked) * @param event */ // do something // call the parents's event } /** * Mousecursor enters Widget. */ // do something } /** * Mousecursor leaves Widget */ // do something } /** * Mousecursor is moved in Widget. */ // do something } };To copy to clipboard, switch view to plain text mode
liqxpil (21st October 2010)
great thanks guys![]()
Bookmarks