kishoreksnair
20th January 2012, 05:50
we need to get the cursor position every time when we move the mouse on desktop.
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
qDebug()<<"event Filter Mouse Move"<<mouseEvent->pos().x()<<mouseEvent->pos().y();
}
if (event->type() == QEvent::FocusOut)
{
QFocusEvent *focusEvent = static_cast<QFocusEvent*>(event);
focusEvent->accept();
qDebug()<<"event Filter Mouse Move111"<<QCursor::pos();
}
return false;
}
Using the above we can get the cursor position inside the Qt application and also get the cursor position when we click on the window outside the Qt app.In our project we need the cursor position on Mousemove outside the QT app.How can we do this ?
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
qDebug()<<"event Filter Mouse Move"<<mouseEvent->pos().x()<<mouseEvent->pos().y();
}
if (event->type() == QEvent::FocusOut)
{
QFocusEvent *focusEvent = static_cast<QFocusEvent*>(event);
focusEvent->accept();
qDebug()<<"event Filter Mouse Move111"<<QCursor::pos();
}
return false;
}
Using the above we can get the cursor position inside the Qt application and also get the cursor position when we click on the window outside the Qt app.In our project we need the cursor position on Mousemove outside the QT app.How can we do this ?