我想使Flickable区域中的Scrollbar.vertical始终可见。当前,单击后可见。文本区域也与滚动条重叠。我如何在以下QML代码中用文本区域分隔滚动条
import QtQuick 2.0
import QtQuick.Controls 2.0
Flickable {
id: flickable
anchors.fill: parent
TextArea.flickable: TextArea {
text: "The Qt QML module provides a framework for developing applications and libraries with the QML language.
It defines and implements the language and engine infrastructure, and provides an API to enable application developers to
extend the QML language with custom types and integrate QML code with JavaScript and C++.
The Qt QML module provides both a QML API and a C++ API.
Note that while the Qt QML module provides the language and infrastructure for QML applications,
the Qt Quick module provides many visual components, model-view support, an animation framework,
and much more for building user interfaces.
For those new to QML and Qt Quick, please see QML Applications for an introduction to writing QML applications."
wrapMode: TextArea.Wrap
font.pixelSize: 20
}
ScrollBar.vertical: ScrollBar {
width: 40
}
}
Run Code Online (Sandbox Code Playgroud)
如果升级到Qt 5.9,则QtQuick.Controls 2.2引入一个policy可以提供帮助的属性,例如
import QtQuick 2.0
import QtQuick.Controls 2.2
Flickable {
id: flickable
...
ScrollBar.vertical: ScrollBar {
width: 40
anchors.left: parent.right // adjust the anchor as suggested by derM
policy: ScrollBar.AlwaysOn
}
}
Run Code Online (Sandbox Code Playgroud)
如果BaCaRoZzoactive建议的 - 属性设置为,那么它似乎每隔几秒就会被计时器覆盖。因此,您可以使用- 信号将其重置为每次。trueonActiveChangedtrue
不过,您也可以通过将 的 设置为 1 来禁用它。opacity至少contentItem对我来说,这可以解决问题。
要确定您的定位:只需锚定它即可。
Flickable {
id: myflickable
...
ScrollBar.vertical: myvertscroll
clip: true
}
ScrollBar {
id: myvertscroll
anchors.left: myflickable.right
contentItem.opacity: 1
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5127 次 |
| 最近记录: |