I'm working on a PDF reader with PyQt4 and python-popplerqt4. PDF pages (QPixmaps) are displayed into QLables, laid out vertically in a QFrame. The QFrame is placed into QScrollArea.
QMainWindow
|_ QScrollArea
|_ QFrame (Document: stretch)
|_ QLabel (Page: fixed size)
| |_ QPixmap (stretch)
|_ QLabel
| |_ QPixmap
|_ etc.
The size of the document is determined by the fixed size of the QLabels. The QPixmap is set to stretch accordingly and the QFrame around pages naturally adjusts its size.
When I call for a zoom, pages (QLabels) are resized one by one with QLabel.setFixedSize()
. The effect however is disappointing: resizing the document looks rickety and flickery. Zooming in Evince or Mendeley is really smooth in comparison.
I have read elsewhere that calling QFrame.hide()
before scaling and QFrame.show()
after helps. Indeed it does for a small document. However, applied to a PDF of about 700 pages for instance, means a blank QScrollArea for more than a second. Not good.
How can I scale the document in the QScrollArea and produce a smooth zoom effect?
PS: The images of the Poppler.Pages are drawn for the visible QLabel recipients only. i.e. resizing a document of 700 pages does not involve resizing as many images. It will in fact resize 2 to 4 images at the maximum (and the more, the less the resolution). Resizing the Document object then consists merely in resizing QLabels, for the most part empty.