Results 1 to 14 of 14

Thread: drag mouse problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default drag mouse problem

    Hi,
    i want when i clic on object and drag the mouse cursor the object move to the new position
    i have
    Qt Code:
    1. void My_app:mousePressEvent(QMouseEvent* evt)
    2. void My_app::mouseMoveEvent(QMouseEvent *e)
    3. {
    4. if(e->buttons().testFlag(Qt::LeftButton))
    5. {
    6. Ogre::Real offsetX =(double)e->pos().x()/(double)width();
    7. Ogre::Real offsetY=(double) e->pos().y()/(double)height();
    8.  
    9.  
    10.  
    11. mRayScnQuery = mSceneMgr->createRayQuery(Ogre::Ray());
    12.  
    13.  
    14.  
    15. Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(offsetX, offsetY);
    16.  
    17.  
    18. mRayScnQuery->setRay(mouseRay);
    19. // Execute query
    20. Ogre::RaySceneQueryResult &result =mRayScnQuery->execute();
    21. Ogre::RaySceneQueryResult::iterator itr;
    22.  
    23. Ogre::RaySceneQueryResult::iterator target;
    24. float shortestDistance = -1 ;
    25.  
    26. for( itr = result.begin() ;itr != result.end();++itr)
    27. {
    28.  
    29. if( itr->distance < shortestDistance || shortestDistance < 0 )
    30. {
    31. // remember the closest
    32. shortestDistance = itr->distance;
    33. target = itr;
    34. }
    35.  
    36. }
    37.  
    38.  
    39.  
    40. Ogre:: Vector3 point=mouseRay.getPoint(target->distance);
    41. emit move_object(point);
    42. }
    To copy to clipboard, switch view to plain text mode 
    the problem is the mouse move event do not work exactelly , it give me always the same position( point posiiton is the same) even if i move the mouse

    i know that's maybe i do
    Last edited by robel; 2nd November 2015 at 11:06.

Similar Threads

  1. QDockWidget: difference between move() and mouse drag
    By MrRipple in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2013, 08:30
  2. Replies: 4
    Last Post: 18th April 2012, 18:11
  3. Drag/Drop on middle mouse button?
    By joeld42 in forum Qt Programming
    Replies: 0
    Last Post: 21st August 2010, 00:20
  4. incorrect QGraphicsItemGroup mouse drag behavior
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2008, 10:05
  5. Mouse Drag selction Issue in QListWidget
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 21st February 2007, 08:55

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.