Results 1 to 13 of 13

Thread: QGraphicsItem reimplemented mouse events

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem reimplemented mouse events

    If you say it's ok then I believe you. It's just that I haven't abuse of anything. I wanted to use some of the simpler features and I've gotten several more headaches than when I tried to learn other qt tools. But anyways, there is no way I'm going to look at the mouseEvent code and understand it. But thaks for the encouragment.

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

    Default Re: QGraphicsItem reimplemented mouse events

    Well, I did have a look. It's very educating to solve your problems by looking into Qt's source code, you should try it. Based on the code I can say that if your item doesn't have any flags set (ItemIsMovable or ItemIsSelectable (the others are ignored), to be exact), you shouldn't call the implementation of mousePressEvent from QGraphicsItem because the event will be ignored and forwarded to an item laying below or to the scene which will probably do something that causes incorrect behaviour of mouseReleaseEvent.
    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
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem reimplemented mouse events

    Well, that basically fits nicely with why I had to pass the events to the QGraphicsItem::mousePressEvents() in my other class, that Item effectively needed to be moveable.

    I'll try what you tell me some time.

    Thanks.

  4. #4
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem reimplemented mouse events

    So I decided to have a look too. I've searched for the code on the web and found it here:
    http://www.koders.com/cpp/fid93B09A1...+mdef%3Ainsert

    (To be honest I can't find it in Linux)

    I think I see what you mean, but there still there is something that I don't understand.

    I was calling QGraphicsItem::mousePressEvent() in my reimplementation of the mousePress and that event did work, however according to the code here if my item is neither moveable or selectable it should also be ignored, what am I missing?

  5. #5
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem reimplemented mouse events

    Ok, so I've read your original answer and now i get that you've allready answered my own question.

    I'm sorry.

    Thanks.

Similar Threads

  1. QGraphicsItem no mouse events called
    By munna in forum Qt Programming
    Replies: 11
    Last Post: 9th December 2009, 14:43
  2. QGraphicsItem mouse events
    By zgulser in forum Qt Programming
    Replies: 13
    Last Post: 11th February 2009, 11:19
  3. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  4. Replies: 9
    Last Post: 22nd June 2008, 22:26
  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
  •  
Qt is a trademark of The Qt Company.