PDA

View Full Version : Mouseevents on a QwebView or WebEngineView



Tinu
7th April 2015, 07:57
Im new in this Forum and new to Qt .
On a WebView I try to reimplement a MouseEvent. The Application start without a error but the qDebug message doesn't appear.
Please check my code...


Thanks for help
Webtest.h


#include <QWidget>
#include <QWebEngineView>
#include <QMouseEvent>

class WebPageMapster : public QWebEngineView
{
public:
WebPageMapster();
~WebPageMapster();


protected:
void mousePressEvent(QMouseEvent *event);
};


webtest.cpp


WebPageMapster::WebPageMapster()
{
load(QUrl("http://google.ch"));
resize(800,600);
show();


}

void WebPageMapster::mousePressEvent(QMouseEvent *event){
if (event->button()== Qt::LeftButton){
qDebug() << "Test";
}
}

anda_skoa
7th April 2015, 09:03
Is the mousePressEvent handler called at all?

Cheers,
_

Tinu
7th April 2015, 10:42
Hi

Yes. on a other Widget I can call the mousePressEvent()

Best

anda_skoa
7th April 2015, 11:36
No, I meant on the web engine view.

I am asking because QWebEngineView overwrites the event() method (according to the documentation), so it might not call the QWidget event handlers at all.

You can try overwriting event() yourself, checking for the mouse press there and just pass on the even after that.

Cheers,
_

Tinu
7th April 2015, 13:50
I've debuged the Events on the WebEngineView.
Only the Enter Event 10) and the ContextMenu (Event 82,68,69) Events are ermited.
How can Implement those MouseEvents? Or is there a other solution to paint a QRubberband on the WebEngineView by Mouse?

Best

anda_skoa
8th April 2015, 08:51
You could check the code of QWebEngineView to see how it intercepts the mouse events.
Maybe it uses an event filter and you could install your own "on top" of that.

Cheers,
_