Results 1 to 7 of 7

Thread: Adding events to GraphicsView

  1. #1
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Adding events to GraphicsView

    Hi all,
    I work with qtdesigner. I created windows with a graphicsview. I could add graphic items to scene. Now i want to add mouse release event to this graphicsview.

    void MainWindow::mouseReleaseEvent(QMouseEvent *event)
    {
    printf("Mouse released\n");
    QGraphicsView::mouseReleaseEvent(event);
    }

    But it doesnt work. How can i do that in simple way.

  2. #2
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding events to GraphicsView

    No.
    Subclass QGraphicsView and override the necessary funtions there.
    Note that you can also subclass the items themselves and react fro mouse actions already there

  3. #3
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding events to GraphicsView

    I need a simple example.

  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: Adding events to GraphicsView

    Quote Originally Posted by mkarakaplan View Post
    I need a simple example.
    Yeah, of course, but before could you please
    • Use the [ CODE ] tags that your example code is shown probably
    • Use the Newbie forum for questions that sort of
    • Tell us what you want to achieve once you get the release event, because I guess you don't need all this...

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding events to GraphicsView

    QWidget is an ancestor of graphics view. So you get mouseReleaseEvent in graphics view. You just need to override the function QAbstractScrollArea::mouseReleaseEvent

  6. #6
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding events to GraphicsView

    I wrote here., but no one helped. During all day i tried a lot.

    http://www.qtcentre.org/forum/f-newb...ighlight=scene

  7. #7
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding events to GraphicsView

    Quote Originally Posted by mkarakaplan View Post
    I wrote here., but no one helped. During all day i tried a lot.

    http://www.qtcentre.org/forum/f-newb...ighlight=scene
    You derive from QGraphicsView, but the constructor takes another QGraphicsView, and your scene is using that view....

Similar Threads

  1. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  2. Replies: 9
    Last Post: 22nd June 2008, 22:26
  3. Replies: 1
    Last Post: 21st August 2007, 16:25
  4. How to suppress user defined events in processEvents()
    By Artschi in forum Qt Programming
    Replies: 5
    Last Post: 5th July 2007, 10:17
  5. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25

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.