我想在Flickable
中添加一些文本,也可以使用键向上和向下滚动。它可以工作,但滚动条在已经褪色后用键滚动时不会显示。鼠标滚轮滚动效果很好。
-style universal
未显示
-style material
未显示
-style default
显示
这是我的代码:
import QtQuick 2.7
import QtQuick.Controls 2.2
ApplicationWindow
{
visible: true
width: 640
height: 480
Flickable
{
anchors.fill: parent
flickableDirection: Flickable.VerticalFlick
focus: true
TextArea.flickable: TextArea
{
text:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna " +
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
"ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna " +
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
"ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna " +
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
"ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna " +
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
"ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " ;
font.pixelSize: 25
wrapMode: TextArea.Wrap
readOnly: true
}
ScrollBar.vertical: ScrollBar { id: scrollBar }
// up/down keys described here:
// https://doc-snapshots.qt.io/qt5-5.8/qml-qtquick-controls2-scrollbar.html
Keys.onUpPressed: scrollBar.decrease()
Keys.onDownPressed: scrollBar.increase()
}
}
感谢您的帮助。
答案 0 :(得分:0)
我推荐这样的移动应用程序:
ScrollBar.vertical: ScrollBar {
id: scrollBar
policy: ScrollBar.AlwaysOn
interactive: false
}
您可以看到:policy和interactive道具。