Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3346578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:19:14+00:00 2026-05-18T01:19:14+00:00

I am using the mouseMoveEvent to track the position of the mouse cursor in

  • 0

I am using the mouseMoveEvent to track the position of the mouse cursor in a simple QT app. My problem is that I want the mouseMoveEvent to fire only when the cursor is in a 400×400 QWidget. Right now it is firing no matter where the mouse is. Here is my code…

void IPA2::mouseMoveEvent(QMouseEvent * event) {
     cout << event->x() << endl;
     cout << event->y() << endl;
}

IPA2 is the name of my class. The ui was created in designer mode.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:19:15+00:00Added an answer on May 18, 2026 at 1:19 am

    If I understand you correctly, you may just perform a check here like if (x,y in range) do_something.

    Another way would be to create a fake widget with 400×400 dimensions and reimplement it’s mouse event.

    The third (probably an overkill) is to use event filters (see here).

    Update:

    You can’t just “easily” handle the mouse events using the Qt Designer. Each .ui scheme is almost always paired up with the corresponding implementation for that scheme. This is where your handling should be done.

    Qt Designer is great for automatic signal-slot handling, but mouseMoveEvent is an event and has nothing to do with the slot system.

    I would say how would I implement this and you can choose (see the three possible ways before).

    I would create some DummyWidget, which would have a 400×400 dimensions and custom virtual mouseMoveEvent method, which would actually handle the mouse movement.

    In the constructor of my main window (which also does the .ui-based construction) I would say something like

    dummy_widget_ = new DummyWidget(...);
    // `dummy_widget_` is a private `DummyWidget*` member of the main window
    

    and then probably would reposition it somewhere.

    That’s it – now when my main window is created, a dummy widget is added to it and every mouse movement at that widget is handled (because we’ve provided custom implementation).

    Another moment, which is related to mouse events only: http://doc.qt.nokia.com/4.7/qwidget.html#mouseTracking-prop

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a c++ console application that grabs the mouse position at regular
Can I get cursor position at mousedown(event) event, without using mousemove(event) continuously (thus waisting
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using mercurial, I've run into an odd problem where a line from one committer
Is there a way to bind to the mouse position in WPF in the
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using the activerecord reload command in my app seems to be using cached data
I'm building a simple white board app in ActionScript 3. Most white board or
I am trying to create an app in Qt/C++ with Qt4.5 and want the
From research on Stack Overflow and other sites I'm 99% sure that the problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.