PDA

View Full Version : Getting Cursor position within QMdiSubWindow



stevel
9th March 2012, 19:56
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:



doc->mapFromGlobal(QCursor::pos())

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

high_flyer
12th March 2012, 12:09
What code should I use to get the position relative to the SubWindow, rather then the main window?

mySubWindow->mapFromGlobal(QCursor::pos()); //'mySubWindow' is your QMdiSubWindow