Please suggest some example for capturing mouse movement co-ordinates X,Y position in the entire windiow??

  • I want to know some Example program to capture mouse movement position of X,Y co-ordinates value in the Window Title.

  • Moderators

    Something like this?


    #ifndef WIDGET_H
    #define WIDGET_H

    #include <QWidget>
    #include <QString>
    #include <QMouseEvent>

    class Widget : public QWidget

    explicit Widget(QWidget *parent = 0) : QWidget(parent) {

    void mouseMoveEvent(QMouseEvent *e) {
    QString str = QString("Mouse is at (%1,%2).").arg(e->x()).arg(e->y());

    #endif // WIDGET_H

    Caveat: just quick and dirty. I haven't tested the code.

  • Thanks a lot ..mlong

  • Moderators

    No problem! Good luck!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.