It seems to me that you need to check whether you are above such a map and ignore (pass) the event in this case. I think you should do something like this:
bool GraphicsWebView::isOverMap(QPoint pos) { QWebPage* webPage = this->page(); if (webPage) { QWebFrame* webFrame = webPage->frameAt(pos); if (webFrame) { QString selectorQuery = "#map-canvas"; // Based on https://developers.google.com/maps/tutorials/fundamentals/adding-a-google-map QList<QWebElement> list = webFrame->findAllElements(selectorQuery).toList(); // Find all the maps! foreach(QWebElement element, list) { if (element.geometry().contains(pos)) { return true; // Cursor is over a map } } } } return false; // No match }
Obviously, this is a rather specific function, but there is probably a way to get a better selector query that will apply to all of these QWebElement types.
Assuming you hook mouse events by subclassing QGraphicsWebView and overriding void mouseMoveEvent(QGraphicsSceneMouseEvent * event) , I suggest you do something like:
void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (isOverMap(mapFromScene(event->scenePos()).toPoint())) {
This part of the document explains how events are processed with respect to the topmost element. I especially recommend you read the third paragraph.
Hope this helps!
EDIT: A bit more research, and it looks like something like this might be more general: graphicsView.focusItem()->flags().testFlag(QGraphicsItem::ItemIsMovable);
This is at least worth considering as a replacement for isOverMap()
EDIT: Gotcha, here is what you can try. Start by subclassing QGraphicsSceneMouseEvent and add a signal named void destroyedWithoutAccept() , which is emitted in the destructor if the event is not accepted.
Then change mouseMoveEvent to look like this:
void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { MyEvent myEvent = new MyEvent(event); // Copy event event.accept(); // accept original event connect(myEvent, SIGNAL(destroyedWithoutAccept), this, SLOT(handleMoveView)); // Callback if unused QGraphicsWebView::mouseMoveEvent(myEvent); // Pass it to Base class }
If this works, it may cause a delay if deleteLater is used to destroy it. But in this case also override it.