Results 1 to 15 of 15

Thread: Can't trigger mousePressEvent on QGraphicsPixmapItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    24
    Thanked 17 Times in 14 Posts

    Default Re: Can't trigger mousePressEvent on QGraphicsPixmapItem

    Hi,

    You are implementing the movement in the piece itself and not in the scene... Both of them are different as they have different coordinate systems for example.

    I mode some changes in your code to allow the movement of the pieces and to control where the piece if moved to.

    You can get the code here:

    http://www.qlands.com/other_files/Qt...0101112.tar.gz

    I made changes in piece,tile and the boargui.

    Basically I:
    1. removed the events from piece and tile.
    2. Added an type to piece and tile so I can cast them
    3. Added mousepress and mouserelease to the boardgui
    4. In those event I coded some bit so the piece can be moved and control when is taken and dropped
    5. Each piece need a flag movable to true.

    See that I dont use the event of drag and drop. If you want to use those events to set each piece to allow drops but is not really neccesary. You can also use the scene mousemove to check the current tile under the mouse while holding the piece and change its color to indicate that is allowed in that time.

    Hope this helps!

  2. #2
    Join Date
    Nov 2010
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17

    Default Re: Can't trigger mousePressEvent on QGraphicsPixmapItem

    I appreciate your effort, but the dragging is glitchy on my computer. Have a look at this: http://www.screentoaster.com/watch/s...UVVU/dragndrop

    Do I have to repaint the board at the end of mousePressEvent and mouseReleaseEvent?

  3. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    24
    Thanked 17 Times in 14 Posts

    Default Re: Can't trigger mousePressEvent on QGraphicsPixmapItem

    Yes, I saw that. What is happening is that the scene is not refreshing properly as the piece pass under the tile items. It could be a bug. I recommend you to post that as a Thread is this forums.

    Carlos.

  4. The following user says thank you to qlands for this useful post:

    blooglet (17th November 2010)

  5. #4
    Join Date
    Nov 2010
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17

    Default Re: Can't trigger mousePressEvent on QGraphicsPixmapItem

    Alright, thanks!

Similar Threads

  1. Replies: 2
    Last Post: 30th July 2010, 17:44
  2. Replies: 5
    Last Post: 23rd May 2010, 02:09
  3. how to captue sqlite's trigger generated err in QT?
    By BalaQT in forum Qt Programming
    Replies: 10
    Last Post: 14th November 2009, 14:42
  4. Trigger QAction by 'Key_Escape'
    By Raccoon29 in forum Newbie
    Replies: 5
    Last Post: 3rd April 2008, 11:24
  5. QComboBox as a trigger
    By ape in forum Newbie
    Replies: 8
    Last Post: 4th February 2008, 09:57

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.