Results 1 to 4 of 4

Thread: Event detection in non-rectangular region

  1. #1
    Join Date
    Nov 2012
    Posts
    22
    Thanks
    1

    Default Event detection in non-rectangular region

    Hi,

    I have a custom widget which contains some custom drawn areas that should be sensitive to events (e.g. mouse clicks).
    The areas are not always rectangular.
    Is there any Qt way of determining whether or not a click took place inside one of these arbitrarily shaped areas (setting some event-sensitive mask on the widget or sth...)?

    Thanks,
    xdn

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event detection in non-rectangular region

    Since this is a custom widget, you can do anything you like with the mouse events you get.
    So you can test the coordinates of the events against any arbitrary criteria and decide upon success/failure whether to accept or reject the event and whether to do something in response.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2012
    Posts
    22
    Thanks
    1

    Default Re: Event detection in non-rectangular region

    Implementing my own checks would was my first idea as well.
    I just wanted to ensure that there is no Qt mechanism that would save me the time to do this.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event detection in non-rectangular region

    Ah, no, there isn't.

    Depending on how you draw you might be able to re-use data though, e.g. QPainterPath, QRegion, etc.

    Cheers,
    _

Similar Threads

  1. Copy A non-Rectangular Image
    By Parvat in forum Newbie
    Replies: 12
    Last Post: 26th June 2013, 09:49
  2. Why a square button becomes rectangular?
    By marc2050 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2011, 05:46
  3. qtreewidget and drop event detection
    By eric_vi in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2010, 11:20
  4. Mouse press event detection
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2009, 13:08
  5. how to rotate a rectangular region of awidget
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 17th March 2008, 13:39

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.