Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to update size of content in ScrollView ?
Forum Updated to NodeBB v4.3 + New Features

How to update size of content in ScrollView ?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 410 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.
  • R Offline
    R Offline
    r3d9u11
    wrote on last edited by
    #1

    Hello.

    I've just faced the trouble: ScrollView doesn't show scroll bars after x:y position of child element was changed (new x:y position greater than original ScrollView's size).

    Is there way to update size of ScrollView's content after child elements were changed ?

    Thanks.

    R 1 Reply Last reply
    0
    • R r3d9u11

      Hello.

      I've just faced the trouble: ScrollView doesn't show scroll bars after x:y position of child element was changed (new x:y position greater than original ScrollView's size).

      Is there way to update size of ScrollView's content after child elements were changed ?

      Thanks.

      R Offline
      R Offline
      r3d9u11
      wrote on last edited by r3d9u11
      #2

      @r3d9u11 so, finally I've replaced ScrollView with Flickable and made function, that is refreshing content size. children elements call it manually:

      Flickable
      {
          id: fieldMap
          anchors.fill: parent
          ScrollBar.horizontal: ScrollBar { active: true; onActiveChanged: { if (!active) active = true; } }
          ScrollBar.vertical: ScrollBar { active: true; onActiveChanged: { if (!active) active = true; } }
          function refreshContentSize()
          {
              fieldMap.contentWidth = fieldMap.width;
              fieldMap.contentHeight = fieldMap.height;
              for (var i = 0; i < fieldMap.contentItem.children.length; ++i)
              {
                  var item = fieldMap.contentItem.children[i];
                  var itemX = item.x+item.width;
                  if ( itemX > fieldMap.contentWidth ) fieldMap.contentWidth = itemX;
                  var itemY = item.y+item.height;
                  if ( itemY > fieldMap.contentHeight ) fieldMap.contentHeight = itemY;
              }
          }
      }
      

      Maybe there is better solution

      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