C
C
CheGevara2014-06-24 08:29:03
Programming
CheGevara, 2014-06-24 08:29:03

How to track mouse movement over a WebView in QT?

There is a small project (QWidget)
Simple code:

void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
    QString str = QString::number(event->y());
    ui->label->setText(str);
}

Everything works on the form, but the movement is not tracked if the mouse was pressed on the WebView object. When you click the mouse on other objects - tracking starts only when the mouse enters the form.
Question: how to track the mouse on a WebView /and on other objects/ (if possible, then a ready-made code example, I think it's not great =))
Maybe I'm stupid, a beginner in this regard.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Misha Krinkin, 2014-06-24
@kmu1990

class MyView : public QWebView
{
    Q_OBJECT
public:
    MyView(QWidget *parent = 0) : QWebView(parent) {
        setMouseTracking(true);
    }

    void mouseMoveEvent(QMouseEvent *event) {
        qDebug() << event->x() << ", " << event->y();
    }
};

maybe I misunderstood you, but the example above works in Qt 5.3 without problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question