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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:06:34+00:00 2026-05-28T03:06:34+00:00

The question is a bit difficult to explain, but I will try. I have

  • 0

The question is a bit difficult to explain, but I will try.

I have an image of a button:

The base button image

And I also have some animations of it, such as (gif with a single loop, reload it to view the animation!):

Animated button

Also, I have some kind of a pattern:

The button pattern

So, now the question: how to make the button react (for example on clicks/hower/etc) only when the mouse is INSIDE the black part of the pattern, and disallow such reactions when the mouse is out of the scope of this pattern? Without modifiyng the graphical files of course. And of course the pattern itself should be invisible.

I want to make that with help of C++ and Qt.

Just please indicate me at least the path, which functions/classes of Qt should I look for! Because now I am completely lost.

  • 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-28T03:06:34+00:00Added an answer on May 28, 2026 at 3:06 am

    One way I can think of doing this, is installing an event filter on the particular button, by calling the void QObject::installEventFilter ( QObject * filterObj ) method of the button. Documentation can be found here.

    What it boils down to, is creating a QObject specifically for the purpose of filtering mouse events, based on a binary image. All you have to do is override the bool QObject::eventFilter ( QObject * watched, QEvent * event ) method of this new object, and then install that object as the filter for the button. As part of the constructor for this filter class, pass it a reference to the binary image. This binary image reference will sit as a member variable in the filter object, and we can use it to decide which pixels of the button respond to mouse events.

    In the eventFilter method:

    • Check the event type, if it is not a mouse event, don’t handle the event yourself, pass it on to the parent class
    • If it is a mouse event, then you’re in business.
    • Get the x and y position of the mouse event using the corresponding methods x() and y()
    • Look into the binary image stored as a member variable. If the binary image is true at that point, do one thing, otherwise do something else

    This filter class should be generic enough that you can create multiple instances of it with different binary images for different buttons/widgets.

    Hope this helps.

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

Sidebar

Related Questions

This will be a bit difficult to explain but I will try my best.
I have little bit longer question for you - but hope answer will be
It might be a bit difficult to explain, so I'll give some example code.
Probably this is not a difficult question, but I am always a little bit
I apologize if this question is a bit broad, but I'm having a difficult
I have a bit of a difficult algorithm question, I can't find any suitable
Bit support question. Apologies for that. I have an application linked with GNU readline.
I think the question is a bit silly, but for a newbie startup building
This might be a little bit odd question, but Im trying to figure out
Was little bit difficult to formulate the title for my question since is kind

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.