Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ScrollView: How does Rectangle will fit in the Scroll view completely

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

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 726 Views
  • 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 Offline
    S Offline
    ShrikantAmbade
    wrote on last edited by
    #1

    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
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by Eddy
      #2

      @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
      0
      • EddyE 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.

        S Offline
        S Offline
        ShrikantAmbade
        wrote on last edited by
        #3

        @Eddy Thanks Eddy :)

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by Eddy
          #4

          you're welcome,

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved