The util module

Small utilities and simple base classes for the qpageview module.

class Rectangular[source]

Bases: object

Defines a Qt-inspired and -based interface for rectangular objects.

The attributes x, y, width and height default to 0 at the class level and can be set and read directly.

For convenience, Qt-styled methods are available to access and modify these attributes.

x = 0
y = 0
width = 0
height = 0
setPos(point)[source]

Set the x and y coordinates from the given QPoint point.

pos()[source]

Return our x and y coordinates as a QPoint(x, y).

setSize(size)[source]

Set the height and width attributes from the given QSize size.

size()[source]

Return the height and width attributes as a QSize(width, height).

setGeometry(rect)[source]

Set our x, y, width and height directly from the given QRect.

geometry()[source]

Return our x, y, width and height as a QRect.

rect()[source]

Return QRect(0, 0, width, height).

class MapToPage(transform)[source]

Bases: object

Simple class wrapping a QTransform to map rect and point to page coordinates.

rect(rect)[source]

Convert QRect or QRectF to a QRect in page coordinates.

point(point)[source]

Convert QPointF or QPoint to a QPoint in page coordinates.

class MapFromPage(transform)[source]

Bases: qpageview.util.MapToPage

Simple class wrapping a QTransform to map rect and point from page to original coordinates.

rect(rect)[source]

Convert QRect or QRectF to a QRectF in original coordinates.

point(point)[source]

Convert QPointF or QPoint to a QPointF in original coordinates.

class LongMousePressMixin(*args, **kwargs)[source]

Bases: object

Mixin class to add support for long mouse press to a QWidget.

To handle a long mouse press event, implement longMousePressEvent().

longMousePressEnabled = True

Whether to enable handling of long mouse presses; set to False to disable

longMousePressTolerance = 3

Allow moving some pixels before a long mouse press is considered a drag

longMousePressTime = 800

How long to presse a mouse button (in msec) for a long press

longMousePressEvent(ev)[source]

Implement this to handle a long mouse press event.

timerEvent(ev)[source]

Implemented to check for a long mouse button press.

mousePressEvent(ev)[source]

Reimplemented to check for a long mouse button press.

mouseMoveEvent(ev)[source]

Reimplemented to check for moves during a long press.

mouseReleaseEvent(ev)[source]

Reimplemented to cancel a long press.

rotate(matrix, rotation, width, height, dest=False)[source]

Rotate matrix inside a rectangular area of width x height.

The matrix can be a either a QPainter or a QTransform. The rotation is 0, 1, 2 or 3, etc. (Rotate_0, Rotate_90, etc…). If dest is True, width and height refer to the destination, otherwise to the source.

align(w, h, ow, oh, alignment=132)[source]

Return (x, y) to align a rect w x h in an outer rectangle ow x oh.

The alignment can be a combination of the Qt.Alignment flags. If w > ow, x = -1; and if h > oh, y = -1.

alignrect(rect, point, alignment=132)[source]

Align rect with point according to the alignment.

The alignment can be a combination of the Qt.Alignment flags.

sign(x)[source]

Return the sign of x: -1 if x < 0, 0 if x == 0, or 1 if x > 0.

signalsBlocked(*objs)[source]

Block the pyqtSignals of the given QObjects during the context.

autoCropRect(image)[source]

Return a QRect specifying the contents of the QImage.

Edges of the image are trimmed if they have the same color.

tempdir()[source]

Return a temporary directory that is erased on app quit.