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. QListView vertical scroll bar not showing up.
Forum Updated to NodeBB v4.3 + New Features

QListView vertical scroll bar not showing up.

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 880 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.
  • E Offline
    E Offline
    Ekta
    wrote on last edited by
    #1

    Hey,
    I am a Qt beginner. I need help with the QListView vertical scrollbar.

    The issue is that there is a QListView that has a list of items. Below that there is a hack to draw something directly into the viewport (An image is drawn). The whole list has no knowledge about it at all.
    In this scenario, the vertical scrollbar (set as ScrollAsNeeded) is not showing up.
    Could someone help me with what can I add so that when we shrink the app, a vertical scroll bar shows up instead of the image getting cut off.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You draw something directly in the viewport of QListView ? Then you should also override the size() and sizeHint() functions so the ScrollArea knows the correct size.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • E Offline
        E Offline
        Ekta
        wrote on last edited by
        #3

        Thank you Christian for your response.

        I have already overridden sizeHint & minimumSizeHint methods. I tried setting viewportSizeHint but it also didn't work.

        Also, on debugging, the viewport size hint shows (-1,-1). I am not sure what could the issue here?

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, from a quick look the sizeHint will not help. You have to adjust the size of the viewport() but I doubt it will really work.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Ekta
            wrote on last edited by
            #5

            Yeah, it didn't work.

            So is it that there is no direct way to solve this?
            So as a Qt beginner, is it that drawing directly to the QListview viewport is not a proper way of placing an image?
            Is there a better way to deal with this issue?

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Don't paint in the viewport but in a widget below

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Ekta
                wrote on last edited by
                #7

                Thanks, Christian. I really appreciate your help here.
                Just to confirm if I understood correctly,
                To add a new widget below the QListView and paint on that newly added widget instead of viewport?

                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Yes. Painting inside a table/list (and outside a cell) is something I've never seen before.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1

                  • Login

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