Results 1 to 8 of 8

Thread: Mouse grabbing - Question for experts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Mouse grabbing - Question for experts

    QGraphicsView can manage the mouse event so you don't need transparent overlay to do it.

    What I would do is to make the items to register touch start/move/end and qgraphicsview to register touch move only.
    now when user touches the screen item registeres the touch and if next action is release - then the song is played (signal emited etc).
    if instead of release, next action is move, item registers it and shouldn't play the song on release (simple bool set to true on touch and to false on move will do, check the bool on release to know what to do).
    this way touch-release will play a song, but touch-move-release will not.
    last step is to implement scrolling in qgraphics view move event handler and you're good to go.

    I hope that's not too vague and gives you my general idea (to mimic ios touch/scroll). I did something like that in js and it worked well.

  2. #2
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Mouse grabbing - Question for experts

    Quote Originally Posted by fullmetalcoder View Post
    Is there anything preventing you from handling mouse events directly in the graphics view without messing with mouse grabbing?
    Maybe I failed to make this clear but this question was part of my (bigger) question. If there was a way for widgets in a view to get all mouse click-move-release events without having to grab the mouse (as soon as you accept() an event you grab the mouse) then my problem would be fixed.


    Added after 6 minutes:


    Quote Originally Posted by Spitfire View Post
    QGraphicsView can manage the mouse event so you don't need transparent overlay to do it.

    What I would do is to make the items to register touch start/move/end and qgraphicsview to register touch move only.
    now when user touches the screen item registeres the touch and if next action is release - then the song is played (signal emited etc).
    if instead of release, next action is move, item registers it and shouldn't play the song on release (simple bool set to true on touch and to false on move will do, check the bool on release to know what to do).
    this way touch-release will play a song, but touch-move-release will not.
    last step is to implement scrolling in qgraphics view move event handler and you're good to go.

    I hope that's not too vague and gives you my general idea (to mimic ios touch/scroll). I did something like that in js and it worked well.
    I see exactly what you want to do and that happens to be what I also want to do. The problem is not if I use an overlay widget or not (I think). My problem is that if I grab the mouse events (accept() the mouse click event) then no other widget will receive the move and release events until the button is released. And in the other way, if a widget don't accept the click event then it will not receive the move and release events... I see now way whatsoever for all the widgets to receive all the events. And that is the core of my problem !

    Thanks for your answer
    Last edited by jfmartel; 21st October 2011 at 08:22.

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouse grabbing - Question for experts

    Quote Originally Posted by jfmartel View Post
    If there was a way for widgets in a view to get all mouse click-move-release events without having to grab the mouse (as soon as you accept() an event you grab the mouse) then my problem would be fixed.
    Event filter?
    Current Qt projects : QCodeEdit, RotiDeCode

  4. The following user says thank you to fullmetalcoder for this useful post:

    jfmartel (23rd October 2011)

  5. #4
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Mouse grabbing - Question for experts

    Quote Originally Posted by fullmetalcoder View Post

    Ok, I'll dig into that.

  6. #5
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Mouse grabbing - Question for experts

    Okay,

    Thanks all for your answers. With your help, I discovered the use of Event filters today and it will be very usefull in my Qt future

    Once I understood how filters worked then what you said guys was right. Overlaying widgets was not necessary. I only filtered the usefull events and I get good control over the event propagation. It's a very clever system.

    Thanks to all of you who took time to post.

Similar Threads

  1. A programming style question for you experts...
    By scott_hollen in forum Newbie
    Replies: 3
    Last Post: 10th February 2011, 20:35
  2. Replies: 2
    Last Post: 21st June 2009, 06:04
  3. Changing mouse grabbing behavior?
    By FlyingSaucrDude in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2008, 01:04
  4. grabbing position of mouse
    By safknw in forum Qt Programming
    Replies: 10
    Last Post: 28th June 2008, 15:00
  5. Experts, what IDE are you using ?
    By probine in forum General Discussion
    Replies: 29
    Last Post: 15th July 2006, 23:03

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.