gpt4 book ai didi

qt - 如何使滚动条在 QML 中的 Flckable 上始终可见

转载 作者:行者123 更新时间:2023-12-03 07:33:36 25 4
gpt4 key购买 nike

我想让 Flickable 区域中的 Scrollbar.vertical 始终可见。目前它在点击时可见。此外,文本区域与滚动条重叠。如何在以下qml代码中将滚动条与文本区域分开enter image description here

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
}
}

最佳答案

如果升级到 Qt 5.9,QtQuick.Controls 2.2介绍了 policy 可以提供帮助的属性(property),例如

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
}
}

关于qt - 如何使滚动条在 QML 中的 Flckable 上始终可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42189391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com