The scrollarea module¶
ScrollArea, that supports kinetic scrolling and other features.
- class ScrollArea(parent=None, **kwds)[source]¶
Bases:
QAbstractScrollArea
A scroll area that supports kinetic scrolling and other features.
- alignment = 132¶
how to align the scrolled area if smaller than the viewport (Qt.AlignmentFlag.AlignCenter)
- scrollupdatespersec = 50¶
how many scroll updates to draw per second (50, 50 is recommended).
- kineticScrollingEnabled = True¶
whether the mouse wheel and PgUp/PgDn keys etc use kinetic scrolling (True)
- draggingEnabled = True¶
If enabled, the user can drag the contents of the scrollarea to move it with the mouse.
- areaPos()[source]¶
Return the position of the area relative to the viewport.
The alignment attribute is taken into account when the area is smaller than the viewport (horizontally and/or vertically).
- offsetToEnsureVisible(rect)[source]¶
Return an offset QPoint with the minimal scroll to make rect visible.
If the rect is too large, it is positioned top-left.
- ensureVisible(rect, margins=None, allowKinetic=True)[source]¶
Performs the minimal scroll to make rect visible.
If the rect is not completely visible it is scrolled into view, adding the margins if given (a QMargins instance). If allowKinetic is False, immediately jumps to the position, otherwise scrolls smoothly (if kinetic scrolling is enabled).
- canScrollBy(diff)[source]¶
Does not scroll, but return the actual distance the View would scroll.
diff is a QPoint instance.
- scrollForDragging(pos)[source]¶
Slowly scroll the View if pos is close to the edge of the viewport.
Can be used while dragging things.
- scrollTo(pos)[source]¶
Scroll the View to get pos (QPoint) in the top left corner (if possible).
Returns the actual distance moved.
- scrollBy(diff)[source]¶
Scroll the View diff pixels (QPoint) in x and y direction.
Returns the actual distance moved.
- kineticScrollTo(pos)[source]¶
Scroll the View to get pos (QPoint) in the top left corner (if possible).
Returns the actual distance the scroll area will move.
- kineticScrollBy(diff)[source]¶
Scroll the View diff pixels (QPoint) in x and y direction.
Returns the actual distance the scroll area will move.
- kineticAddDelta(diff)[source]¶
Add diff (QPoint) to an existing kinetic scroll.
If no scroll is active, a new one is started (like kineticScrollBy).
- steadyScroll(diff)[source]¶
Start steadily scrolling diff (QPoint) pixels per second.
Stops automatically when the end is reached.
- class Scroller[source]¶
Bases:
object
Abstract base class, encapsulates scrolling behaviour.
A Scroller subclass must implement the step() and finished() methods and may define additional methods.
- class SteadyScroller(speed, updates_per_second)[source]¶
Bases:
Scroller
Scrolls the area steadily n pixels per second.