qt - QML Qt 快速控制按钮在 Raspberry PI 3B 上不显示背景颜色
问题描述
我的 QML 应用程序的按钮在我的按钮上没有显示任何背景颜色。
我正在使用 Material 主题并尝试更改 qtquickcontrols2.conf 文件中的设置,但设置按钮背景属性仍然没有运气。看起来这通常会使用强调色,但这种颜色从未真正设置,但主背景和前景色确实有效。
示例文件:
[Controls]
Style=Material
[Universal]
Theme=System
Accent=Yellow
Background=Green
Foreground=Orange
Primary=Pink
[Material]
Theme=Light
Background=Grey
Foreground=Black
Accent=Purple
Primary=Blue
Palette\Button=#212121
当我记录特定按钮上可用的值时,它会变得更有趣:
ml: objectName:
qml: parent: Button_QMLTYPE_22(0x2100568)
qml: data: [object Object]
qml: resources: [object Object]
qml: children: [object Object]
qml: x: 0
qml: y: 6
qml: z: -1
qml: width: 360
qml: height: 88
qml: opacity: 1
qml: enabled: true
qml: visible: true
qml: visibleChildren: [object Object]
qml: states: [object Object]
qml: transitions: [object Object]
qml: state:
qml: childrenRect: QRectF(0, 0, 360, 88)
qml: anchors: QQuickAnchors(0x2261900)
qml: left: QVariant(QQuickAnchorLine, )
qml: right: QVariant(QQuickAnchorLine, )
qml: horizontalCenter: QVariant(QQuickAnchorLine, )
qml: top: QVariant(QQuickAnchorLine, )
qml: bottom: QVariant(QQuickAnchorLine, )
qml: verticalCenter: QVariant(QQuickAnchorLine, )
qml: baseline: QVariant(QQuickAnchorLine, )
qml: baselineOffset: 0
qml: clip: false
qml: focus: false
qml: activeFocus: false
qml: activeFocusOnTab: false
qml: rotation: 0
qml: scale: 1
qml: transformOrigin: 4
qml: transformOriginPoint: QPointF(180, 44)
qml: transform: [object Object]
qml: smooth: true
qml: antialiasing: true
qml: implicitWidth: 64
qml: implicitHeight: 36
qml: containmentMask: null
qml: layer: QQuickItemLayer(0x221c2e0)
qml: color: #d6d7d7
qml: gradient: undefined
qml: border: QQuickPen(0x207b528)
qml: radius: 2
我可以看到颜色已设置并且我应该能够看到我的按钮。此数据来自打印附加到背景属性的所有属性。
另一个奇怪的问题是,当我在一个树莓派模型 3b 模型 v1 但不是树莓派 3b 模型 v1.2 上运行 QML 应用程序时,我能够显示背景颜色
我也浏览了源代码:
background: Rectangle {
implicitWidth: 64
implicitHeight: control.Material.buttonHeight
radius: 2
color: !control.enabled ? control.Material.buttonDisabledColor :
control.highlighted ? control.Material.highlightedButtonColor : control.Material.buttonColor
PaddedRectangle {
y: parent.height - 4
width: parent.width
height: 4
radius: 2
topPadding: -2
clip: true
visible: control.checkable && (!control.highlighted || control.flat)
color: control.checked && control.enabled ? control.Material.accentColor : control.Material.secondaryTextColor
}
// The layer is disabled when the button color is transparent so you can do
// Material.background: "transparent" and get a proper flat button without needing
// to set Material.elevation as well
layer.enabled: control.enabled && control.Material.buttonColor.a > 0
layer.effect: ElevationEffect {
elevation: control.Material.elevation
}
Ripple {
clipRadius: 2
width: parent.width
height: parent.height
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
color: control.flat && control.highlighted ? control.Material.highlightedRippleColor : control.Material.rippleColor
}
}
设置了所有应该显示背景的变量,所以我有点难过。
运行 boot2qt 5.15.2
解决方案
推荐阅读
- javascript - 在正文脚本功能完成之前,Chrome 扩展的 readyState 已完成
- scala - scala中的隐式类未按预期显示输出
- validation - TensorFlow Object Detection API - 验证损失增加而 mAP 也增加?
- python - 部分标签索引上的 Pandas MultiIndexing KeyError
- java - 使用 CyclicBarriers 进行服务器和客户端之间的持续通信
- c# - Hello World dotnet 二进制文件的预期大小是多少?(并且可以达到 2kB 吗?)
- c++ - 派生类返回分配的基类实例
- c - 求和函数的有趣字符输出 (Φw ÅΩw)
- javascript - mousedown 事件不是连续的,仅运行一次
- azure-sql-database - DBA 是否可以绕过 Azure 临时表?