Results 1 to 4 of 4

Thread: The function QGraphicsScene::itemAt problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    15
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default The function QGraphicsScene::itemAt problem

    Hi all,

    I've created a custom class (named as Flow) inherited by QGraphicsItem. It's composing of an arrow and curve. I've used the function itemAt to determine which item has selected when QGraphicsScene::mousePressEvent is called. But it does not always return correct item. Otherwise I've written the folllowing function for manual detection. It's working correctly. But I want to learn why sometimes QGraphicsScene can not detect item selected by pressing mouse? Is there a more sensible method than manual point control?

    Qt Code:
    1. int getMatchedFlow(QPointF pos)
    2. {
    3. int fID = -1;
    4. QList<Flow*> mFlowList = mGroupStore.keys();
    5. QList<Flow*>::iterator i;
    6. Flow *pFlow;
    7.  
    8. for (i = mFlowList.begin(); i != mFlowList.end(); ++i)
    9. {
    10. pFlow = (Flow*)*i;
    11. if (pFlow->checkPointSet(pos))
    12. {
    13. fID = pFlow->getID();
    14. break;
    15. }
    16. }
    17.  
    18. return fID;
    19. }
    20.  
    21. bool Flow::checkPointSet(QPointF point)
    22. {
    23. bool rc = false;
    24.  
    25. if (mBoundingPath.contains(point))
    26. {
    27. rc = true;
    28. }
    29.  
    30. return rc;
    31. }
    To copy to clipboard, switch view to plain text mode 

    Thanks a lot for your helps,
    Last edited by yaseminyilmaz; 2nd April 2012 at 10:12.

Similar Threads

  1. Replies: 5
    Last Post: 30th July 2014, 23:52
  2. Move function for widget won't works in QGraphicsScene
    By alizadeh91 in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2012, 09:43
  3. Replies: 1
    Last Post: 16th April 2011, 08:23
  4. QTreeWidget itemAt
    By maartenS in forum Newbie
    Replies: 4
    Last Post: 17th September 2008, 19:19
  5. Order of elemetns with QGraphicsScene::itemAt
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2006, 21:00

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.