qml桌面组件扩展
qml desktop components scaling
我想创建一个可以缩放并包含一些桌面组件的用户界面qtquick2。正如这篇博客文章中提到的,qml/qtquick2的默认呈现应该使用距离字段,而不是本地文本呈现。我试着缩放qt快速控制。结果相当令人失望。我在测试ubuntu 64和qt-5.1.1。控件上的文本看起来很糟糕,但标准qml元素(text/TextEdit)中的所有文本在缩放时看起来都很好。
这让我认为原生渲染现在是桌面组件的默认渲染。这个能打开吗?
在Qt 5.2中将使用样式(例如TextArea
:)设置Qt Quick Controls的渲染类型
TextArea {
/* ... */
style: TextAreaStyle {
renderType: Text.QtRendering
}
}
支持的渲染类型有:
Text.QtRendering
Text.NativeRendering
(默认)
参见TextArea.qml、TextAreaStyle.qml.
对于Button
和ButtonStyle
,没有公共接口可以直接在Qt 5.2中设置渲染类型。但你可以做的是用你自己的文本组件覆盖label
:
Button {
id: theButton
/* ... */
style: ButtonStyle {
label: Item {
implicitWidth: row.implicitWidth
implicitHeight: row.implicitHeight
property var __syspal: SystemPalette {
colorGroup: theButton.enabled ?
SystemPalette.Active : SystemPalette.Disabled
}
Row {
id: row
anchors.centerIn: parent
spacing: 2
Image {
source: theButton.iconSource
anchors.verticalCenter: parent.verticalCenter
}
Text {
renderType: Text.NativeRendering /* Change me */
anchors.verticalCenter: parent.verticalCenter
text: theButton.text
color: __syspal.text
}
}
}
}
此代码的灵感来自ButtonStyle.qml的默认label
组件,该组件经过修改且未经测试。
我不认为您可以更改Qt组件中的文本呈现,因为它们是为桌面应用程序明确设计的。
例如,在TextArea中,没有像TextEdit中那样的renderType
。
在QtDesktopComponents页面上,我看到了另一个提示:
您必须将QGuiApplication更改为QApplication。这是因为组件依赖于某些特定于小部件的类(如QStyle)来进行本机渲染。
相关文章:
- 是否可以通过C++扩展强制多个python进程共享同一内存
- 如何将 txt 文件中的行分隔为组件C++
- static_assert在宏中,但也可以扩展到可以用作函数参数的东西
- 如何将这个C++哈希表转换为动态扩展和收缩,而不是使用硬设置的最大值
- 扩展光电二极管探测器以支持多个传感器
- 使用不同的CRT将新的C++代码与旧的(二进制)组件隔离开来的最佳方法是什么
- C++中的VLA,扩展名为std=C++11
- 到连接组件算法的问题(递归)
- OpenGL 和 GLM 矩阵无法正确扩展,总是按比例缩小
- 基于范围的 for 循环:迭代使用一个元素扩展的向量
- C++返回 Numpy 数组的 Python 扩展模块
- 两个 COM 组件中 ENUM 的重复条目
- 扩展可变参数模板中的变量名称
- 为什么 gcc 会产生这种奇怪的组件与叮当声?
- 使用 bfs 解决连接组件问题时得到错误的答案
- 如何在ECS框架中更新组件数据和通知系统
- 我的火狐扩展程序不起作用。使用C++XPCOM组件的Firefox扩展(XPI文件)的结构是什么?
- qml桌面组件扩展
- c++扩展Windows WRL组件类不工作
- Firefox扩展/插件二进制组件向后兼容性