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. Problems with ScrollBar and ListView
Forum Updated to NodeBB v4.3 + New Features

Problems with ScrollBar and ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 778 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.
  • C Offline
    C Offline
    Circuits
    wrote on 1 Dec 2021, 22:00 last edited by Circuits 12 Jan 2021, 22:12
    #1

    I have a couple of problems when customizing a ScrollBar in a ListView. The first problem I have is that the bar is only ever visible when I am either: hovering the bar or scrolling the list. This makes it a poor indicator to the user that there is more content available then they can currently see in the list.

    In order to get around this I customize the bar a bit like so:

        ScrollBar.vertical: ScrollBar
        {
          height: parent.height
          width: 30
          policy: ScrollBar.AsNeeded
          contentItem: Rectangle
          {
            color: themeManager.currentTheme.palette.highlightColor
            radius: 5
            opacity: 1
          }
          rightPadding: 10
        }
    

    This allows the bar to always be visible; however, that is a problem because I only want the bar to be visible when it is needed.

    So, if I set the visible property of the Rectangle like so:

    visible: parent.active
    

    then it will only show up when it's needed but I am back to the original problem...

    Is there a way to have the bar be visible at all times when it is needed? Not just when I scroll the list or when I hover the bar but always but ONLY when it makes sense to actually have a scrollbar.

    Essentially, what I need to figure out is how this policy property works. That does seem to work correctly in that the scroll bar will only ever show up if it is needed but I can't set the visibility of my contentItem to be "parent.whenparentisneeded" now can I..

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Circuits
      wrote on 1 Dec 2021, 22:24 last edited by
      #2

      I figured it out. For anyone who's interested. If you set the visibility of the contentItem to be:

      visible: theListView.contentHeight > theListView.height
      

      that should do the trick.

      1 Reply Last reply
      0

      1/2

      1 Dec 2021, 22:00

      • Login

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