Results 1 to 5 of 5

Thread: Passing a QMouseEvent to a QGraphicsScene

  1. #1
    Join Date
    May 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Passing a QMouseEvent to a QGraphicsScene

    I created a qGLWidget that is the parent to a QGraphicsScene, I have bypassed the use of a qGraphicsView. Ive read that a qGraphicsView handles all the mouse events for a qGraphicsScene and passes the events to it after making it into a qgraphicscenemouseevent.

    Ive looked through the source for change between a QMouseEvent and a QGraphicsSceneMouseEvent and I am attempting to use that as my basis for creating a qgraphicsscenemouseevent from the qglwidget. I would like to know it is even possible to pass a mouse event from a qglwidget to qgraphicsscene? and how to pass?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing a QMouseEvent to a QGraphicsScene

    Hi, you could use QCoreApplication::postEvent or QCoreApplication::sendEvent to send events to the QGraphicsScene.

    Ginsengelf

  3. #3
    Join Date
    May 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Passing a QMouseEvent to a QGraphicsScene

    Does the type of event matter? I am getting a QMouseEvent, and from what i understand a QGraphicsScene requires a QGraphicsSceneMouseEvent.

  4. #4
    Join Date
    May 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Passing a QMouseEvent to a QGraphicsScene

    I was able to get my scene to accept the the mouse event using a QCoreApplication::sendEvent however it is not passing the event down to my qgraphicsitems do i follow the same process for the items or is there a way to send from the scene?

  5. #5
    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: Passing a QMouseEvent to a QGraphicsScene

    When you write "I was able to get my scene to accept the the mouse event" do you mean that it created the respective QGraphicsSceneMouseEvent?

    Because my understanding was that this is done by the view.

    Cheers,
    _

Similar Threads

  1. QMouseevent
    By jerkymotion in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2011, 07:58
  2. QMouseEvent
    By Fallen_ in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2010, 05:17
  3. how to catch qMouseEvent
    By pakine in forum Newbie
    Replies: 0
    Last Post: 5th July 2010, 17:16
  4. QMouseEvent
    By shenakan in forum Newbie
    Replies: 1
    Last Post: 20th August 2009, 14:53
  5. qmouseEvent handling
    By nass in forum Qt Tools
    Replies: 9
    Last Post: 13th October 2006, 08:55

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.