ScrollView: How does Rectangle will fit in the Scroll view completely
-
Hello,
I am trying to draw rectangle inside the ScrollView. But when I use ScrollView and put my Rectangle in it, rectangle only has define height and width it does not fit my whole screen.
Bellow is my code:
ColumnLayout {
id: layout
anchors.fill: parent
SplitView {
anchors.fill: parent
orientation: Qt.HorizontalScrollView{ Layout.maximumWidth: 400 Layout.minimumWidth: 100 Rectangle { width: ScrollView.viewport.width height:ScrollView.viewport.height color: "lightblue" Text { text: "View 1" anchors.centerIn: parent } } } ScrollView{ Layout.minimumWidth: 150 Layout.fillHeight: true Layout.fillWidth: true Rectangle { width:1000 height: 1000 color: "lightgreen" Text { text: "View 3" anchors.centerIn: parent } } } } }
-
@ShrikantAmbade said:
ScrollView{ Layout.maximumWidth: 400 Layout.minimumWidth: 100 Rectangle { width: ScrollView.viewport.width height:ScrollView.viewport.height color: "lightblue"
changes to make :
give ScrollView an id : and use that id eg. v1 to set width and height like this in the Rectangle block :width : v1.width
ScrollView is just a type and not a component like v1, so you cannot get a specific measurement from it.
-
@ShrikantAmbade said:
ScrollView{ Layout.maximumWidth: 400 Layout.minimumWidth: 100 Rectangle { width: ScrollView.viewport.width height:ScrollView.viewport.height color: "lightblue"
changes to make :
give ScrollView an id : and use that id eg. v1 to set width and height like this in the Rectangle block :width : v1.width
ScrollView is just a type and not a component like v1, so you cannot get a specific measurement from it.
@Eddy Thanks Eddy :)