Results 1 to 4 of 4

Thread: Handling parent und child events at once.

  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Handling parent und child events at once.

    Hi, I'm trying to subclass QGraphicsView and put a QGraphicsScene in it. I found out, that it is very easy to implement moving items in the scene, just by setting item flags. Unfortunately my QGraphicsView class has to deal with the same mouse events as its scene, so the mouse events don't reach the scene, which means I can't move the items anymore. I know, that it's possible to pass an event to the superclass, but I couldn't figure out, how to forward it to a member after processing the parents code. I need something like this:

    Qt Code:
    1. void mouseDoubleClickEvent (QMouseEvent* event){
    2.  
    3. if (some_condition) {
    4. // process the QGraphicsView stuff
    5. }else{
    6. // forward the event to the scene
    7. }
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

  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: Handling parent und child events at once.

    I assume you have subclassed QGraphicsScene. Then simply use QGraphicsScene::mouseDoubleClickEvent(event); in your else statement.

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Handling parent und child events at once.

    i don't have subclassed QGraphicsScene. As i said, my class is derived from QGraphicsView and there is a QGraphicsScene as a member in it.

  4. #4
    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: Handling parent und child events at once.

    ok, then install an eventfilter for your scene.

Similar Threads

  1. mouse events handling with QGraphicsItem
    By trallallero in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2009, 15:15
  2. Replies: 9
    Last Post: 22nd June 2008, 23:26
  3. QGraphicsView Handling Child Event
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 01:32
  4. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 19:44
  5. handling keyboard events from a console app
    By g.cavallin in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2006, 23:31

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.