简体   繁体   English

Qt:隐藏然后显示QQuickView可以防止未来的鼠标事件

[英]Qt: hiding then showing QQuickView prevents future mouse events

I have a QQuickView I've embedded over another widget using createWindowContainer(). 我有一个QQuickView我使用createWindowContainer()嵌入了另一个小部件。

quickView = new QQuickView(...);
container = new QWidget();
createWindowContainer(quickView, container);

Then I add the container widget to the widget that's inside the window. 然后我将容器小部件添加到窗口内的小部件。

layout = new QVBoxLayout();
fullWindowWidget->setLayout(layout);
layout->addWidget(container);

This seems to work fine render-wise but it seems like the QQuickView QML scene doesn't handle mouse events if I hide then show the container. 这似乎可以很好地渲染,但如果我隐藏然后显示容器,似乎QQuickView QML场景不处理鼠标事件。 If I launch the app with the container visible, it handles the mouse events fine. 如果我在容器可见的情况下启动应用程序,它会处理鼠标事件。 But if I start with the container hidden and show the container, any clicks on the container seem to be bubbled up to the widget behind it. 但是,如果我从隐藏的容器开始并显示容器,那么对容器的任何点击似乎都会冒泡到它后面的小部件。 Does hiding the container put the QQuickView in a strange state that prevents clicks even when it's visible again? 隐藏容器是否会使QQuickView处于一种奇怪的状态,即使再次可见时也会阻止点击?

It looks like I was calling grabMouse() on the main window. 看起来我在主窗口上调用了grabMouse() Calling releaseMouse() before showing the container seemed to fix it. 在显示容器之前调用releaseMouse()似乎可以修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM