How do I detect a mouse movement in a QImage
Hi,
I've been trying for a while now to find out if a mouse moves over a QImage object. I can get the mouse movement from the main application but not just the QImage Object which is what I am trying to accomplish. Anyone know how I can find out? I'm using Kdevelop in KDE 3.4 Gnarg |
AFAICS it's not possible to do that, because the virtual mouseMoveEvent() is defined in QWidget which is not one of the parent classes of QImage.
This does makes sense, because a QImage is a in-memory object to hold image-data, and in memory there's no such thing as a mouse pointer... |
Ah yes, that does make sense. Then I'm not asking the right question.
In order for me to display an image I need to set the clipping rect and then display the image. Then if I'm asking this right how can I trap mouse movements in the clipping rect? What I am trying to accomplish is displaying an image in a small part of the application, which is already done. When the mouse moves over this image change the mouse pointer to a cross hair and when it leaves the image restore it. That's it. I'm not really concerned where the mouse is other then if its over the image being displayed. Even on any widget if I can learn to trap mouse movements then I should be able to learn from that. I've looked at Trolltech example page on mouseEvents and it did not help me to trap mouseMovements for any specific widget, only the main window. Hope that makes more sense. Gnarg |
when you declare your class just set up a handler
i use QCanvasView as an example but any QWidget will work Code:
class viewer : public QCanvasView { Code:
void viewer::contentsMouseMoveEvent(QMouseEvent* e) |
All times are GMT -5. The time now is 06:13 PM. |