如何从 QML 的显示中删除/移除屏幕/页面?
我有一个 Loader
,用它来加载多个屏幕/页面。
我有大约 10 个 QML 屏幕/页面,我正在通过鼠标事件将它们一一加载到加载器中。
在某些屏幕上,我需要使用 QWidget::setMask() 函数设置透明度,以使屏幕/页面的某些部分变得透明并在屏幕上打孔。
我正在使用 rootObject
上的 QWidget::setMask()
从 CPP 代码设置掩码,这是 Loader
屏幕。
QWidget::setMask
工作正常,但屏蔽区域显示先前加载的屏幕/页面。
所以我有一个问题,在 Loader
中加载新屏幕/页面之前,Loader
元素是否正确地从显示器中删除/删除加载的组件,如文档 http://doc.qt.nokia.com/4.7-snapshot/qml-loader.html。
还有两个名为 Component.onDestroyed
和 Component.onDestruction
的函数,
当我在 Loader 中加载新屏幕/页面时,onDestruction
事件被触发已加载屏幕。
一旦我们在加载器中加载新页面,我想从显示器上完全删除/销毁屏幕/页面。 我还尝试设置先前加载的屏幕的可见性和不透明度,但我仍然能够在遮罩区域中看到先前加载的屏幕/页面。
如果我设置了 loader 的 source = ""
和 sourceComponent = undefined
那么我也可以在 Loader 中看到上一个加载的页面,它不会刷新屏幕。上一页已被销毁,但不会从显示中清除/删除。
应该是什么原因呢?
I have one Loader
using which I am loading the multiple screen/pages.
I have around 10 QML screen/pages which I am loading in the loader one by one on mouse events.
On some of the screens I need to set transparency using QWidget::setMask()
function to make some part of the screen/page make transparent and Punch hole the screen.
I am doing set mask from CPP code using QWidget::setMask()
on the rootObject
, which is Loader
screen.
QWidget::setMask
is working perfectly, but masked area displays previously loaded screen/page.
So I have the question, Is Loader
element properly deletes/removes the loaded component from the display before loading the new screen/page in the Loader
, as mentioned in documents http://doc.qt.nokia.com/4.7-snapshot/qml-loader.html.
Also there are two function named Component.onDestroyed
and Component.onDestruction
When I load new screen/page in the Loader onDestruction
event is getting fired for the Loaded screen.
I want to completely remove/destroy the screen/page from the display once we load new page in the loader.
I have also tried to set the visibility and opacity of the previously loaded screen, but still I am able to see the Previously loaded screen/page in the masked area.
If I set loader's source = ""
and sourceComponent = undefined
then also I can see the previous loaded page in Loader, it is not refreshing the screen. The previous page is destroyed but it is not cleared/removed from the display.
What should be the reason?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过在加载的 qml 文件中接收信号
Component.onDestruction
或在onSourceChanged
中使用 C++ 中的QWidget::clearMask()
函数?代码>加载器?Have you tried using
QWidget::clearMask()
function in C++ when receiving signalComponent.onDestruction
in loaded qml file or when receivingonSourceChanged
inLoader
?