Results 1 to 8 of 8

Thread: restricting mouse move

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    116
    Thanked 42 Times in 41 Posts

    Default restricting mouse move

    Hi friends,

    Is it possible to move the mouse cursor only in a particular region of a graphicsview or scene . i just want to restrict the mouse move only in specific rectangular region.
    currently i tried eventFilter but is there any other way ...


    Thanks & Regards,
    Wagmare
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: restricting mouse move

    Do you want to restrict the physical cursor or received mouse events? In other words, what do you need it for?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    116
    Thanked 42 Times in 41 Posts

    Default Re: restricting mouse move

    Thanks for reply ...
    this is my requirement ... im having a window (graphicsView) with an ellipse or circle at the center which covers the 70% of the region and remaining portions im having some buttons at right and bottom side of the window.
    my task is
    when user clicks a button i have to move the cursor to that ellipse region and the mouse move should be within that ellipse bounding region..

    Thanks once region ..
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: restricting mouse move

    That doesn't really answer my question Do you want to restrict the physical cursor pointer (I don't think Qt can do that) or mouse events you're getting from the widget (Graphics View can do that)? If the requirement is to force the user to choose some point from within a restricted area then restricting events should be enough.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    116
    Thanked 42 Times in 41 Posts

    Default Re: restricting mouse move

    Once again thanks for the reply ..
    i want to restrict the events into the particular area ... inside an ellipse area ...

    Thanks
    "Behind every great fortune lies a crime" - Balzac

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: restricting mouse move

    In that case basically you have two options, both involving QGraphicsItem::itemChange(). If you have an item which you want to restrict to a certain area then reimplement itemChange() for that item and monitor QGraphicsItem::ItemPositionChange changes to see whether the items wants to be placed outside your area of interest and prevent that by returning a position from inside that area. If you don't have an item but rather want to force a user to click within the area then hide the mouse pointer (by setting it to a blank shape), create a dedicated item that will serve as a cursor, optionally grab the mouse to that shape and then use itemChange() like I described earlier.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following 2 users say thank you to wysota for this useful post:

    alizadeh91 (15th April 2012), wagmare (29th March 2012)

  8. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    116
    Thanked 42 Times in 41 Posts

    Default Re: restricting mouse move

    Im going to use ur second option ... thanks !!
    "Behind every great fortune lies a crime" - Balzac

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: restricting mouse move

    Oh, and of course enable mouse tracking.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. disable mouse move
    By karlkar in forum Newbie
    Replies: 0
    Last Post: 4th January 2011, 20:47
  2. How to move the mouse ?
    By shad0w in forum Newbie
    Replies: 3
    Last Post: 2nd November 2008, 14:55
  3. Move mouse over object
    By ToddAtWSU in forum Qt Programming
    Replies: 17
    Last Post: 3rd October 2007, 16:53
  4. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 07:26
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 06:34

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
  •  
Qt is a trademark of The Qt Company.