Results 1 to 2 of 2

Thread: How to make only part of a button react on user actions based on graphical shape?

  1. #1
    Join Date
    Jan 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to make only part of a button react on user actions based on graphical shape?

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

    I have an image of a button:




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



    Also, I have some kind of a 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.
    Last edited by Evengard; 13th January 2012 at 03:12.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to make only part of a button react on user actions based on graphical shape?

    A simple solution would be to subclass QPushButton and reimp mousePressEvent. There you check if event->pos() is in the region of the black area. Only if true propagate the event to the base class.

Similar Threads

  1. Logging Qt User Actions
    By Frank J. Lhota in forum Qt Programming
    Replies: 14
    Last Post: 30th May 2014, 22:36
  2. How to make the push button to curly shape?
    By harish in forum Qt Programming
    Replies: 3
    Last Post: 29th November 2011, 18:21
  3. Replies: 1
    Last Post: 6th November 2009, 11:03
  4. Replies: 3
    Last Post: 10th April 2009, 15:49
  5. shape of push button
    By Seema Rao in forum Qt Programming
    Replies: 23
    Last Post: 2nd April 2008, 02:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.