Results 1 to 2 of 2

Thread: Getting Cursor position within QMdiSubWindow

  1. #1
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Getting Cursor position within QMdiSubWindow

    I am trying to do something that I think should be pretty simple, but I seem to be missing something. If someone could enlighten me, I would appreciate it.

    What I want is the cursor position relative to the upper left hand corner of my current window, which is a QMdiSubwindow. The code I am trying to use to get this is the following:

    Qt Code:
    1. doc->mapFromGlobal(QCursor::pos())
    To copy to clipboard, switch view to plain text mode 
    Where Doc is a QGraphicsView that is inside a QMdiSubWindow.

    What this seems to be giving me is the cursor position relative to my QMainWindow, and when I step into mapFromGlobal, it seems to go
    to the parent of the object, rather then looking at the QMdiSubWindow, which is how it gets to the QMainWindow.

    What code should I use to get the position relative to the SubWindow, rather then the main window?

    Thanks for any help,

    -Steve Lamperti

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Getting Cursor position within QMdiSubWindow

    What code should I use to get the position relative to the SubWindow, rather then the main window?
    Qt Code:
    1. mySubWindow->mapFromGlobal(QCursor::pos()); //'mySubWindow' is your QMdiSubWindow
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. get cursor position from another running application
    By tinysoft in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2010, 01:20
  2. Cursor Position in scene
    By rogerholmes in forum Newbie
    Replies: 2
    Last Post: 12th March 2010, 16:31
  3. How to get the position of a QMdiSubWindow
    By doberkofler in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2009, 19:35
  4. Replies: 6
    Last Post: 30th May 2007, 10:25
  5. Cursor scene position
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2006, 14:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.