QScrollArea shows full size even when setting FitToWidth
-
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
-
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.