Results 1 to 4 of 4

Thread: GraphicsSceneMouseRelease don't works on top item

  1. #1
    Join Date
    Jul 2007
    Location
    Russia, Ul'yanovsk
    Posts
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default GraphicsSceneMouseRelease don't works on top item

    Hi!

    I have two QGraphicsRectItems on a QGraphicsScene. Firts item is parent of second one. On the second item I have installed filter which simply prints message string on press and release event. If filter is installed on the second item, "Release" message will never show. Why? If filter on first, its all OK - both messages are appears.

    http://qtnode.net/index.php/pastebin/5386
    compilable example - http://www.creobyte.com/tools/releaseevent.zip

  2. #2
    Join Date
    Jul 2007
    Location
    Russia, Ul'yanovsk
    Posts
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GraphicsSceneMouseRelease don't works on top item

    So, no ideas?

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: GraphicsSceneMouseRelease don't works on top item

    I didn't try it, but I would guess that the problem is that your second item is not part of the scene (see how you allocated it in comparison to the first one, which is IN the scene).
    The second item is just an allocated item, belongs to no scene, and the filter filters *scene* events.
    Qt Code:
    1. QGraphicsItem *firstItem = scene->addRect(QRectF(10.0, 10.0, 80.0, 80.0)); //added to scen
    2. QGraphicsItem *secondItem = new QGraphicsRectItem(QRectF(20.0, 20.0, 60.0, 60.0)); //not in scene
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jul 2007
    Location
    Russia, Ul'yanovsk
    Posts
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GraphicsSceneMouseRelease don't works on top item

    No, that is not problem. I was not added secondItem to scene, but I set to it firstItem as its parent:
    Qt Code:
    1. secondItem->setParentItem(firstItem);
    To copy to clipboard, switch view to plain text mode 
    So now secondItem is valid member of scene too.

    But even if you are right, why then we can see "Pressed" message?
    Last edited by QCasper; 14th January 2008 at 20:39.

Similar Threads

  1. Replies: 1
    Last Post: 16th October 2007, 22:41
  2. combobox and item colors
    By zorro68 in forum Qt Programming
    Replies: 16
    Last Post: 23rd September 2007, 12:54
  3. Changing selected item color in non-current window.
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2007, 07:09
  4. Replies: 1
    Last Post: 19th April 2007, 22:23
  5. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.