Results 1 to 2 of 2

Thread: How to transform the phisical cooridinate of QMouseEvent to logical coordinate?

  1. #1
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default How to transform the phisical cooridinate of QMouseEvent to logical coordinate?

    I defined a QGLWidget:
    Qt Code:
    1. NLDCanvas = new QGLWidget;
    2. NLDCanvas->setMinimumHeight(305);
    3. NLDCanvas->setMinimumWidth(460);
    To copy to clipboard, switch view to plain text mode 

    I also defined
    Qt Code:
    1. QPainter ipainter(this);
    2. ipainter.setWindow(QRect(50,50,100,100);
    To copy to clipboard, switch view to plain text mode 

    Moreover,In the QGLWidget, I reimplemented the mouseMoveEvent(QMouseEvent *e) function.
    And I need to pick the items under the position of the cursor.

    However, since the e->posF() is according to the physical coordinate, the result does not has the same value of the item's logical coordinate.

    How can I get the logical coordinate of the mouse position of the QGLWidget?

    Thanks a lot

  2. #2
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to transform the phisical cooridinate of QMouseEvent to logical coordinate?

    Quote Originally Posted by superwave View Post
    I defined a QGLWidget:
    Qt Code:
    1. NLDCanvas = new QGLWidget;
    2. NLDCanvas->setMinimumHeight(305);
    3. NLDCanvas->setMinimumWidth(460);
    To copy to clipboard, switch view to plain text mode 

    I also defined
    Qt Code:
    1. QPainter ipainter(this);
    2. ipainter.setWindow(QRect(50,50,100,100);
    To copy to clipboard, switch view to plain text mode 

    Moreover,In the QGLWidget, I reimplemented the mouseMoveEvent(QMouseEvent *e) function.
    And I need to pick the items under the position of the cursor.

    However, since the e->posF() is according to the physical coordinate, the result does not has the same value of the item's logical coordinate.

    How can I get the logical coordinate of the mouse position of the QGLWidget?

    Thanks a lot
    Are you talking about coordinate conversion between OpenGL space coordinate and Qt screen coordinate?

    Regards,
    Dong Back Kim

Similar Threads

  1. Suggestions for logical expression syntax?
    By rakkar in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 20:24
  2. Non logical Errors - qmake
    By ahmhdy in forum Qt Programming
    Replies: 7
    Last Post: 19th June 2009, 21:11
  3. Replies: 0
    Last Post: 24th November 2008, 08:52
  4. little logical question........
    By sudheer in forum Qt Tools
    Replies: 3
    Last Post: 8th May 2008, 14:15
  5. Logical fonts?
    By sdfisher in forum Qt Programming
    Replies: 1
    Last Post: 1st March 2007, 13:01

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.