【发布时间】:2019-11-10 23:11:08
【问题描述】:
嗯.. 我在我的应用程序中通过中继器放置了 22 个这样的滑块元素。移动滑块非常抖动和生涩,这是在我笔记本电脑上的 nvidia gpu 上。这在集成显卡上更流畅。有什么明显可以改进的地方吗?我对 Qt 还很陌生,所以这对我来说是一个难题..
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
}
}
}
【问题讨论】:
-
您运行代码的平台是什么?即使有 56 个控件,您的滑块在我的系统上也能顺利运行。
-
Thinkpad t570 带专用显卡,win10
标签: performance qt slider qtquick2