Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QListWidget scrolling not working properly



  • Hi,

    I have an image that is 800x12000 pixels that I add to QListWidget using addItem method. The trouble is that the vertical scrollbar only allows scrolling down to only the top part of the image. The rest of the image isn't reachable.

    The image is there as I can call .save and then view it from the image file in all it's glory in a photo viewer.

    qic=QtGui.QIcon(QtGui.QPixmap.fromImage(im))
    qtw = QtWidgets.QListWidgetItem()
    qtw.setIcon(qic)
    listWidget.addItem(qtw)
    listWidget.setIconSize(QtCore.QSize(width, height))

    Is this a bug in Qt? How do I get the scrolling in QListWidget to work properly?



  • @TonyB123
    I imagine QListWidget scrolls to (the start of) each item in the list. What do you mean exactly by "How do I get the scrolling in QListWidget to work properly?"?

    P.S.
    Your item is something like 10+ screen-fuls high. You really want that in a list widget?


  • Qt Champions 2019

    @TonyB123 Why do you want to put such a huge image into a QListWidget?!


  • Lifetime Qt Champion

    Hi
    I think a QScrollArea with a QLabel showing image might work better than
    a monster size item.



  • The scrollbar range only allows to see a little of a window height of the image and not the rest of the image. The scrollbar is huge and almost the same height of the window, so moving it down only a bit and it already reaches its limit and only reveals a few more lines of the image.

    I since chopped up the image into smaller chunks and displayed them across multiple QListWidgetItems and the scrolling works for this.


Log in to reply