赞
踩
通过Google发现这个问题是存在的,不仅鼠标事件捕捉不到,paint事件等也捕获不到,https://stackoverflow.com/questions/30566101/how-can-i-get-paint-events-with-qtwebengine。
通过安装事件过滤器来捕获:
QApplication::instance()->installEventFilter(this);
bool WebView::eventFilter(QObject *object, QEvent *event) { if(object->parent() == this) { QEvent::Type et = event->type(); switch(et) { case QEvent::MouseButtonPress: mousePressEvent(static_cast<QMouseEvent *>(event)); break; case QEvent::MouseButtonRelease: mouseReleaseEvent(static_cast<QMouseEvent *>(event)); break; case QEvent::MouseMove: mouseMoveEvent(static_cast<QMouseEvent *>(event)); break; default: break; } } return false; }
以上两步解决问题。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。