Results 1 to 14 of 14

Thread: drag mouse problem

Hybrid View

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

    Default Re: drag mouse problem

    Hi,
    i am not sure if Ogre influence or no
    but i have the mouse press and mouse release event that work
    that's it's code
    mouseReleaseEvent(QMouseEvent* e):
    Qt Code:
    1. void My_app::mouseReleaseEvent(QMouseEvent* e)
    2. {
    3. if(!e->buttons().testFlag(Qt::LeftButton))
    4. {
    5. oldPos = QPoint(invalidMousePoint);
    6. e->accept();
    7. }
    8. else
    9. {
    10. e->ignore();
    11. }
    12. emit mouseRelease(e);
    13. }
    To copy to clipboard, switch view to plain text mode 
    mousePressEvent(QMouseEvent* evt):
    Qt Code:
    1. if(evt->button() == Qt::LeftButton)
    2. {
    3.  
    4.  
    5. Ogre::Real offsetX =(double)evt->pos().x()/(double)width();
    6. Ogre::Real offsetY=(double) evt->pos().y()/(double)height();
    7. move_object(double offsetX ,double offsetY)
    8. }
    9. emit mousePress(evt);
    10. }
    To copy to clipboard, switch view to plain text mode 
    it work mouse press event
    but mouse move event
    Qt Code:
    1. oid QOgreRenderWindow::mouseMoveEvent(QMouseEvent *e)
    2. {
    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. move_object(offsetX,offsetY);
    10. e->accept();
    11. }
    12. emit mouseMove(e);
    13. }
    To copy to clipboard, switch view to plain text mode 
    the mouse work just when i pree when i move nothing it work

  2. #2
    Join Date
    Sep 2015
    Posts
    50
    Qt products
    Qt5
    Platforms
    Unix/X11
    Thanks
    8

    Default Re: drag mouse problem

    Quote Originally Posted by robel View Post
    Hi,
    i am not sure if Ogre influence or no
    but i have the mouse press and mouse release event that work
    that's it's code
    mouseReleaseEvent(QMouseEvent* e):
    Qt Code:
    1. void My_app::mouseReleaseEvent(QMouseEvent* e)
    2. {
    3. if(!e->buttons().testFlag(Qt::LeftButton))
    4. {
    5. oldPos = QPoint(invalidMousePoint);
    6. e->accept();
    7. }
    8. else
    9. {
    10. e->ignore();
    11. }
    12. emit mouseRelease(e);
    13. }
    To copy to clipboard, switch view to plain text mode 
    mousePressEvent(QMouseEvent* evt):
    Qt Code:
    1. if(evt->button() == Qt::LeftButton)
    2. {
    3.  
    4.  
    5. Ogre::Real offsetX =(double)evt->pos().x()/(double)width();
    6. Ogre::Real offsetY=(double) evt->pos().y()/(double)height();
    7. move_object(double offsetX ,double offsetY)
    8. }
    9. emit mousePress(evt);
    10. }
    To copy to clipboard, switch view to plain text mode 
    it work mouse press event
    but mouse move event
    Qt Code:
    1. oid QOgreRenderWindow::mouseMoveEvent(QMouseEvent *e)
    2. {
    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. move_object(offsetX,offsetY);
    10. e->accept();
    11. }
    12. emit mouseMove(e);
    13. }
    To copy to clipboard, switch view to plain text mode 
    the mouse work just when i pree when i move nothing it work
    Instead of an emit, just try calling the base implementation. Comment out the emit calls and add calls like these:

    <parent-class to QOgreRenderWindow>::mouseMoveEvent(e);
    <parent-class to QOgreRenderWindow>::mousePressEvent(e);
    <parent-class to QOgreRenderWindow>::mouseReleaseEvent(e);

    This will allow it to continue processing the message as it normally would. if you execute an emit, it's just going to reprocess your slot code.
    Last edited by Caolan O'Domhnaill; 7th November 2015 at 00:50.

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.