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 3491318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:37:20+00:00 2026-05-18T11:37:20+00:00

OS::win_xp_sp3 Qt::4.6 Is it possible to use QMouseEvent inside QRect? I have parent widget

  • 0

OS::win_xp_sp3

Qt::4.6

Is it possible to use QMouseEvent inside QRect?
I have parent widget and inside is some QLabel with text “status unchanged”.

Also , inside parent widget is MyRect which is derived from QRect.

Now I want to MouseEvent act only inside this MyRect. For example , if I act on MyRect , text in parent widget need to be changed.

For example:

class MyRect : public QRect  {
      public:
      MyRect(int x, int y, int w, int h, ParentWidget* parent)
            : QRect(x,y,w,h) 
            {
               itsParent = parent;
            }
      ~MyRect() {}

      protected:
      void mouseMoveEvent(QMouseEvent* event)  

      private:
      ParentWidget* itsParent

  };  

void MyRect::mouseMoveEvent(QMouseEvent* event)
{
    if(event->buttons() == Qt::LeftButton)
    {
        itsparent->label->setText("status changed");
    }

}

nothing happens

question:: is it possible to use QMouseEvent like this (only on QRect)?

  • 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-18T11:37:21+00:00Added an answer on May 18, 2026 at 11:37 am

    A QRect is neither a QObject nor a QWidget, so it doesn’t receive events.
    It’s just four numbers describing a rectangle (and it doesn’t make sense to derive from it).
    You can check if a point is the given rect in the mouse event handler of your widget. Like:

    void MyLabel::mouseMoveEvent( QMouseEvent* e ) {
        if ( !rect.contains( e->pos() ) )
            return;
        //... handle mouse move
    }
    

    An alternative to subclassing is using an event filter.

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

Sidebar

Related Questions

I have installed Visual Studio 2010 on my pc (WinXP SP3). I am trying
hi i have written app on vs2008 c# (express edition) on win XP which
I recenty stumbled upon some files described as HTML Applications on my Win XP
I am writing a WPF application on WinXP and I have overridden the default
I have several USB drives connected to a WinXP SP3 computer, and I need
Possible Duplicate: trace() not written to flashlog.txt I am trying to log flash trace
I have a VS solution containing several projects. While debugging a particular project all
I have a DTO type declared as follows: [Serializable] public class PersonDTO { public
I have a static library, libsqlite3.a, that i want to link to my small
I have an application that need to send command to cmd and then get

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.