LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-19-2005, 08:54 AM   #1
Gnarg
Member
 
Registered: Feb 2004
Location: Canada
Distribution: Gentoo Linux
Posts: 44

Rep: Reputation: 15
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
 
Old 12-19-2005, 11:20 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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...
 
Old 12-19-2005, 12:48 PM   #3
Gnarg
Member
 
Registered: Feb 2004
Location: Canada
Distribution: Gentoo Linux
Posts: 44

Original Poster
Rep: Reputation: 15
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
 
Old 12-19-2005, 09:44 PM   #4
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
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 {
    Q_OBJECT

public:
    viewer(QCanvas&, QWidget* parent=0, const char* name=0, WFlags f=0);

protected:
    void contentsMousePressEvent(QMouseEvent*);
    void contentsMouseMoveEvent(QMouseEvent*);
now you can handle those events within the QCanvasView
Code:
void viewer::contentsMouseMoveEvent(QMouseEvent* e)
{
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse Movement Problem in DOSbox smannell Linux - Software 14 06-14-2009 03:35 PM
System reboots from mouse movement 24jedi Linux - Hardware 2 06-03-2005 08:42 AM
Choppy mouse movement with xorg 6.7.0-11 tommyr1216 Linux - Hardware 5 01-23-2005 12:48 AM
SlackWare 9.1 Mouse-Constant Movement Zero-0-Effect Slackware 6 12-21-2003 07:43 AM
Optical mouse and choppy movement sienarot Linux - Hardware 7 07-06-2003 06:11 PM


All times are GMT -5. The time now is 07:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration