Performance 滑块上的QML性能
嗯。。在我的应用程序中,我通过中继器放置了22个滑块元素。。移动滑块相当JTTY和Y,这是英伟达GPU在我的笔记本电脑上。这在集成图形上更平滑。。有什么明显的地方我可以改进吗?我是Qt的新手,所以这对我来说是个难题Performance 滑块上的QML性能,performance,qt,slider,qtquick2,Performance,Qt,Slider,Qtquick2,嗯。。在我的应用程序中,我通过中继器放置了22个滑块元素。。移动滑块相当JTTY和Y,这是英伟达GPU在我的笔记本电脑上。这在集成图形上更平滑。。有什么明显的地方我可以改进吗?我是Qt的新手,所以这对我来说是个难题 import QtQuick 2.0 import QtQuick.Controls 2.2 Item { height: 4*82 width: 82 Rectangle { height: 4*82 width: 83
import QtQuick 2.0
import QtQuick.Controls 2.2
Item {
height: 4*82
width: 82
Rectangle {
height: 4*82
width: 83.55
color: "#0a0a0a"
border.color: "#80cccccc"
Rectangle {
width: 83.55
height: 22
color: "#0a0a0a"
border.color: "#80cccccc"
y:parent.y -22
Label {
x:parent.x+parent.width/2 - width/2
y:5
id: name
text: qsTr("MASTER EFX SP")
color: slider.value > 0 ? "#6eaf71" : "#3c3c3c"
font.pixelSize: 10
}
}
}
Slider {
id: slider
from: 0
to: 255
value: 0
orientation: Qt.Vertical
height: (4*82)-32
width: 83.55
y: 16
stepSize: 1.0
handle: Item {
y: parent.topPadding + parent.visualPosition * (parent.availableHeight - 50)
x: parent.leftPadding + parent.availableWidth / 2 - 30 / 2
Rectangle {
color: parent.parent.pressed || parent.parent.value > 0? "#901fdcf5" : "#90ffffff"
border.color: parent.parent.pressed || parent.parent.value > 0? "#1fdcf5" : "gray"
width: 30
height: 50
radius: 2
}
Rectangle {
color: parent.parent.pressed || parent.parent.value > 0? "#80000831" : "#4e4e4e"
width: 30
height: 2
y: 50/2-2
}
}
background: Rectangle {
x: parent.leftPadding + (horizontal ? 0 : (parent.availableWidth - width) / 2)
y: parent.topPadding + (horizontal ? (parent.availableHeight - height) / 2 : 0)
implicitWidth: horizontal ? 200 : 6
implicitHeight: horizontal ? 6 : 200
width: horizontal ? parent.availableWidth : implicitWidth
height: horizontal ? implicitHeight : parent.availableHeight
radius: 0
border.color: "#3c3c3c"
color: "#3c3c3c"
scale: horizontal && parent.mirrored ? -1 : 1
readonly property bool horizontal: parent.orientation === Qt.Horizontal
}
}
}
首先,试着理解出了什么问题——可能根本不是滑块的问题。 用于打开Qml应用程序并检查图形堆栈 从您粘贴的代码中,我认为唯一可能导致问题的是
radius
属性,因为这是您的代码所做的唯一昂贵的事情
另外,尝试将库导入更新为最新的qt版本,您使用的是非常旧的版本,而新的版本也可能会提高性能。首先,尝试了解问题所在-可能根本不是滑块。 用于打开Qml应用程序并检查图形堆栈 从您粘贴的代码中,我认为唯一可能导致问题的是
radius
属性,因为这是您的代码所做的唯一昂贵的事情
另外,尝试将库导入更新为最新的qt版本,您使用的是非常旧的版本,而新版本也可能会提高性能。运行代码的平台是什么?您的滑块在我的系统上运行平稳,即使有56个控件。Thinkpad t570带有专用图形,Win10您运行代码的平台是什么?您的滑块在我的系统上运行平稳,即使有56个控件。带有专用图形的Thinkpad t570,win10