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. Qt 5.0.2/4.8.4 QListView - prevent vertical scrolling and resize vertically to contents
Forum Updated to NodeBB v4.3 + New Features

Qt 5.0.2/4.8.4 QListView - prevent vertical scrolling and resize vertically to contents

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • napajejenunedk0N Offline
    napajejenunedk0N Offline
    napajejenunedk0
    wrote on last edited by
    #1

    I have a QListView that has been given a model. Putting the QListView in a layout makes it squeeze its height, so that it shows only part of the items from the model and the vertical scrollbar appears that allows for browsing the rest of the items. This behavior is due to its QAbstractScrollArea nature.

    What I want is that the QListView resizes vertically, so that it shows all of its items.
    @
    QAbstractScrollArea::setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    @

    only removes the scrollbar, but doesn't make the list view resize vertically to its contents.

    Any suggestions?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you will need to ensure this by yourself. Meaning to listen to model signals for data changes and resize the listview.
      You can use QAbsractItemView::visualRect() and sum up the height for all indexes in the view/model.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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