Results 1 to 20 of 25

Thread: Move Rectangle on mouse Move

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Move Rectangle on mouse Move

    Can you show me again the code?

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Move Rectangle on mouse Move

    Quote Originally Posted by marcel View Post
    Can you show me again the code?
    Qt Code:
    1. void myClass::mouseMoveEvent( QMouseEvent *e ){
    2. if ( !readonly ){
    3. if( band ){
    4. band->move( e->pos()- mouseRectOffset );
    5. return;
    6. }
    7. //some other stuffs regarding application
    8. }
    9. }
    10. void myClass::mousePressEvent( QMouseEvent *e ){
    11. if( e->button() == LeftButton ){
    12. if ( !readonly ){
    13. if(canvasMode == CM_DragDropMode ){
    14. hilitObject->hilight( this, FALSE );
    15. dragSelection( e->pos() );
    16. leftDown = TRUE;
    17. return;
    18. }
    19. //some other stuffs regarding application
    20. }
    21. }
    22. }
    23.  
    24. void myClass::mouseReleaseEvent( QMouseEvent *e ){
    25. if( leftDown ){
    26. leftDown = FALSE;
    27. if( band ){
    28. cacluateNewObjectPosition(e->pos());
    29. delete band;
    30. band = 0;
    31.  
    32. // If the pasteList is not empty (meaning we didn't cancel the
    33. // paste operation), then do the following:
    34. if( ! pasteList.isEmpty() ){
    35. // Update the pixel coordinates
    36. }
    37. update();
    38. return;
    39. }
    40. //some other stuffs regarding application
    41. }
    42. void myClass::pasteObjects(){
    43. //first calculate pasteRect
    44. if( !band )
    45. band = new QRubberBand(QRubberBand::Rectangle, this);
    46. band->setGeometry( pasteRect );
    47. band->show();
    48. }
    49. void myClass::dragSelection( QPoint clickedP ){
    50. //first calculate pasteRect
    51. if( !band )
    52. band = new QRubberBand(QRubberBand::Rectangle, this);
    53. band->setGeometry( pasteRect );
    54. band->show();
    55. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Move Rectangle on mouse Move

    Ok, I'm back again...Can anyone please tell me why there is a lag when I move QRubberBand rectangle???

Similar Threads

  1. Game mouse movement
    By chaosgeorge in forum Qt Programming
    Replies: 1
    Last Post: 2nd December 2006, 23:41
  2. how to display full tree item name on mouse move ?
    By rajesh in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 08:41
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. Replies: 2
    Last Post: 24th July 2006, 18:36
  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.