性能问题
Performance troubles
我在使用这个简单的应用程序时遇到了问题。如果我在按钮之前有背景图片或只是纯矩形(id:下面示例中的背景),它将响应非常缓慢(处理器使用率超过 90%),如果我评论这个背景矩形,应用程序会快速反应,但如果我添加 "enable.layers: true" 到root item,响应慢会回来。
问题出在哪里?
我想要背景图片和快速的点击响应。
我是 运行 这个例子 Raspberry Pi 3.
import QtQuick 2.3
Item {
id: root
visible: true
width: 800
height: 480
Rectangle {
id: background
anchors.fill: parent
smooth: true
}
Rectangle {
id: button
width: 200 ; height: 123
anchors.centerIn: parent
smooth: true
radius: 8
//color the button with a gradient
gradient: Gradient {
GradientStop {
position: 1.0
color: {
if (mouseArea.pressed)
return "red"
else
return "chartreuse"
}
}
GradientStop {position: 0.0; color: "paleturquoise" }
}
MouseArea {
id:mouseArea
anchors.fill: parent
onPressed: {
//handler.turnOn()
}
onReleased: {
// handler.turnOff()
}
}
}
}
它通过在 raspi-config 下启用实验性 GL 解决了这个问题。 QtQuick 1.1 工作正常的原因是由于这个事实:
"In Qt 5, all QML applications are rendered with an OpenGL scenegraph architecture rather than the Graphics View framework used in Qt 4."
我在使用这个简单的应用程序时遇到了问题。如果我在按钮之前有背景图片或只是纯矩形(id:下面示例中的背景),它将响应非常缓慢(处理器使用率超过 90%),如果我评论这个背景矩形,应用程序会快速反应,但如果我添加 "enable.layers: true" 到root item,响应慢会回来。 问题出在哪里?
我想要背景图片和快速的点击响应。 我是 运行 这个例子 Raspberry Pi 3.
import QtQuick 2.3
Item {
id: root
visible: true
width: 800
height: 480
Rectangle {
id: background
anchors.fill: parent
smooth: true
}
Rectangle {
id: button
width: 200 ; height: 123
anchors.centerIn: parent
smooth: true
radius: 8
//color the button with a gradient
gradient: Gradient {
GradientStop {
position: 1.0
color: {
if (mouseArea.pressed)
return "red"
else
return "chartreuse"
}
}
GradientStop {position: 0.0; color: "paleturquoise" }
}
MouseArea {
id:mouseArea
anchors.fill: parent
onPressed: {
//handler.turnOn()
}
onReleased: {
// handler.turnOff()
}
}
}
}
它通过在 raspi-config 下启用实验性 GL 解决了这个问题。 QtQuick 1.1 工作正常的原因是由于这个事实: "In Qt 5, all QML applications are rendered with an OpenGL scenegraph architecture rather than the Graphics View framework used in Qt 4."