PDA

View Full Version : How can we get current cursor position in any part of window from the child class.



pratik041
21st November 2011, 07:06
we have a class
class custom::public QObject
{
Q_OBJECT
public:
custom(QWidget *parent)
{

}
bool event (QEvent *e)
{
//get cursor position.

}
};


suppose we have the above child class. Inside child class event how can we get cursor position irrespective of whether the cursor is on the parent or on the other child of same parent. I have inherited from QObject because i dont want to create any widget in this class just i want to know cursor position to handle other objects.

stampede
21st November 2011, 09:33
const QPoint p = QCursor::pos();

pratik041
21st November 2011, 09:51
I have tried that but i am not getting the cursor position.

d_stranz
23rd November 2011, 00:26
You have shown us nothing about how you *use* this custom class. Showing a class definition is meaningless. How can we possibly answer your question without more information?

Santosh Reddy
23rd November 2011, 00:42
QObject::event() is called only when the object receives an event. Make sure the object receives an event.