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. How to create a smooth zooming effect in a QScrollArea?
Forum Updated to NodeBB v4.3 + New Features

How to create a smooth zooming effect in a QScrollArea?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.4k 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.
  • J Offline
    J Offline
    jesuisbenjamin
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jesuisbenjamin
      wrote on last edited by
      #2

      11 hours later...

      I've tried animating the the resizing of the pages with an animation set in the Page class (so each Page would have its own resize animation). But it didn't work at all---I mean the resizing didn't even take place. I've done animations before, so I'm pretty sure that should work. It gets me even more confused:

      @
      def applyScale(self):
      scale = self.display().scale() / 100
      size = self.source().pageSize() # size provided by Poppler.Page
      self.scale_animation = QtCore.QPropertyAnimation(self, "size")
      self.scale_animation.setDuration(200)
      self.scale_animation.setStartValue(self.size())
      self.scale_animation.setEndValue(QtCore.QSize(size.width() * scale, size.height() * scale))
      self.scale_animation.start()
      @

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jesuisbenjamin
        wrote on last edited by
        #3

        Apparently no simple solution, use QGraphicsView instead. See http://qt-project.org/forums/viewthread/17257/

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fredrossperry
          wrote on last edited by
          #4

          Hello, I am attempting the almost-identical thing. Did you ever get a resolution (haha) to this problem? Thanks.

          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