2016-11-06 6 views
1

ウェブページのように、コンテンツが長方形を超えている場合、スクロールバーがあります。 私を助けることができる他の人はいますか? 私はリストビューで試してみましたが、私は例がFlickableなしScrollBarを使用する方法、ドキュメントであり、長方形QMLで長方形のスクロールバーを作成する方法

+0

それは可能性がありますもう少し詳細を与えるのに役立ち、おそらくあなたが試したことのコードスニペットです。 – wwkudu

+0

[ScrollView](http://doc.qt.io/qt-5/qml-qtquick-controls-scrollview.html)を試してください – folibis

答えて

5

でそれを使用することはできません。

enter image description here

import QtQuick 2.7 
import QtQuick.Controls 2.0 

Rectangle { 
    id: frame 
    clip: true 
    width: 160 
    height: 160 
    border.color: "black" 
    anchors.centerIn: parent 

    Text { 
     id: content 
     text: "ABC" 
     font.pixelSize: 160 
     x: -hbar.position * width 
     y: -vbar.position * height 
    } 

    ScrollBar { 
     id: vbar 
     hoverEnabled: true 
     active: hovered || pressed 
     orientation: Qt.Vertical 
     size: frame.height/content.height 
     anchors.top: parent.top 
     anchors.right: parent.right 
     anchors.bottom: parent.bottom 
    } 

    ScrollBar { 
     id: hbar 
     hoverEnabled: true 
     active: hovered || pressed 
     orientation: Qt.Horizontal 
     size: frame.width/content.width 
     anchors.left: parent.left 
     anchors.right: parent.right 
     anchors.bottom: parent.bottom 
    } 
} 
+2

私はそれがあなたがそのような基本的な項目でその機能を得ることができることがとても素晴らしいと思います。 :) – Mitch

+0

これは今日(2017年12月)と同様に動作するはずですか?なぜなら、私が試してみるときではないからです。 2つのqtページが見つかりません。 – CoderS

+0

Qt 5.9.3とQt 5.10.0で私の仕事をしてください。私はリンクを更新しました。 – jpnurmi

関連する問題