我不知道为什么或如何发生,但Z顺序完全搞砸了。这是显示我的问题的最小例子。测试机器正在Windows 8 x64,Qt 5.1上运行。奇怪的图像行为(Qt快速2)
import QtQuick 2.0
Item {
id: root;
width: 800;
height: 800;
Background {
id: background;
anchors.fill: root;
imageSource: "backgrounds/1.jpg";
}
MainView {
id: mainView;
anchors.fill: root;
}
BottomBar {
id: bottomBar;
anchors.bottom: root.bottom;
anchors.left: root.left;
anchors.right: root.right;
height: 75;
}
这里是背景:
import QtQuick 2.0
import QtGraphicalEffects 1.0
Item {
id: root;
property alias imageSource: imageItem.source;
Image {
id: imageItem;
anchors.fill: root;
fillMode: Image.PreserveAspectCrop;
visible: false;
}
GaussianBlur {
anchors.fill: root;
source: imageItem;
radius: 12;
samples: 12;
deviation: 5;
cached: true;
}
}
的MainView:
import QtQuick 2.0
Item {
id: root;
Rectangle {
anchors.centerIn: root;
width: 500;
height: 500;
color: "red";
}
}
而且BottomBar:
import QtQuick 2.0
Item {
id: root;
Rectangle {
anchors.fill: root;
color: Qt.rgba(.07, .07, .07, .95);
}
的应红色正方形居中在1.JPG的中间以及底部的75px高度线它,但方形是没有看到。
但是,如果我删除背景元素,一切都很好。
感谢您的帮助。
感谢您的帮助。这并没有改变,但我解决了这个问题。不透明度有问题。可能是基于[QuickWidget](https://code.google.com/p/quickwidget/)用于QQuickWindow支持不透明度(透明背景)的封装器中的一个错误。解决方法是将不透明度设置为0.99,如果你想要不透明的项目 – Sh1ne
嗯..实际上,我记得阅读了一些与不透明度有关的bug,通过0.99技巧解决了这个问题,导致所有内容都是“alpha混合”而不是“沿Z顺序覆盖” 。但我不认为这是事实。 IIRC,当你实际上有透明的东西时,这个错误就会显示出来,而你的布局看起来似乎不是(hm,可见的:在imageItem上是false,也许?)。无论如何,很高兴听到你找到它。请写一个简短的答案,并在几天后接受它作为解决方案(我的意思是,你自己的答案),它会将线程标记为“已解决”。 – quetzalcoatl
我有很多元素透明,我也有可见的设置为图像上的错误,因为我使用了GaussianBlur。但事实并非如此。即使我把它设置为假,一切都会变得模糊起来。 – Sh1ne