Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QScrollArea shows full size even when setting FitToWidth
Forum Updated to NodeBB v4.3 + New Features

QScrollArea shows full size even when setting FitToWidth

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 305 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.
  • D Offline
    D Offline
    dullfig
    wrote on last edited by dullfig
    #1

    Hello:

    I am displaying pdf documents in a QScrollArea. I am using a QLabel, and setting the image with setPixmap. I want the image to start out in Fit to width mode, but it is not working.

    Here is the code that sets up the scroll area:

            self.setWidgetResizable(True) 
            inner = QFrame()
            inner.setLayout(QGridLayout())
            self.__pdfImage = QLabel()
            inner.layout().addWidget(self.__pdfImage)
            self.setWidget(inner) 
            
    

    Then elswhere I load the image into __pdfImage:

        def __newPage(self):
            pixmap = self.__document.render(self.__zoomFactor)
            fmt = QImage.Format.Format_RGBA8888 if pixmap.alpha else QImage.Format.Format_RGB888
            qi = QImage(pixmap.samples, pixmap.w, pixmap.h, pixmap.stride, fmt)
            pic = QPixmap.fromImage(qi)
            self.__pdfImage.setPixmap(pic)
            self.__zoomMode = self.ZoomMode.FitToWidth
           
    

    But the image shows full size, not resized to fit into the area. Any ideas?

    Dan

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dullfig
      wrote on last edited by
      #2

      anyone have any ideas?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You're not giving enough information.
        What is ZoomMode ?
        How is it used ?
        Whiche version of PySide/PyQt are you using ?
        On which OS ?

        A minimal runnable example would allow us to test your issue more easily.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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