Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved ScrollView: How does Rectangle will fit in the Scroll view completely

    General and Desktop
    2
    4
    583
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      ShrikantAmbade last edited by

      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.Horizontal

              ScrollView{
      
                  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
                  }
              }
             }
      
          }
      
      
      
      }
      
      1 Reply Last reply Reply Quote 0
      • E
        Eddy last edited by Eddy

        @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.

        Qt Certified Specialist
        www.edalsolutions.be

        S 1 Reply Last reply Reply Quote 0
        • S
          ShrikantAmbade @Eddy last edited by

          @Eddy Thanks Eddy :)

          1 Reply Last reply Reply Quote 0
          • E
            Eddy last edited by Eddy

            you're welcome,

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply Reply Quote 0
            • First post
              Last post