The util module¶
Small utilities and simple base classes for the qpageview module.
- class Rectangular[source]¶
Bases:
objectDefines 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¶
- class MapToPage(transform)[source]¶
Bases:
objectSimple class wrapping a QTransform to map rect and point to page coordinates.
- class MapFromPage(transform)[source]¶
Bases:
MapToPageSimple class wrapping a QTransform to map rect and point from page to original coordinates.
- class LongMousePressMixin(*args, **kwargs)[source]¶
Bases:
objectMixin 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
- class Point(x, y)[source]¶
Bases:
QPointAn overflow-safe QPoint.
This works around an oversight in PyQt, which does not constrain integer arguments to fixed sizes as used in C++, causing an OverflowError when those limits are exceeded.
- rotate(matrix, rotation, width, height, dest=False)[source]¶
Rotate matrix inside a rectangular area of width x height.
The
matrixcan be a either a QPainter or a QTransform. Therotationis 0, 1, 2 or 3, etc. (Rotate_0,Rotate_90, etc…). Ifdestis True,widthandheightrefer to the destination, otherwise to the source.
- align(w, h, ow, oh, alignment=<AlignmentFlag.AlignCenter: 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 Qt.AlignmentFlag values. If w > ow, x = -1; and if h > oh, y = -1.
- alignrect(rect, point, alignment=<AlignmentFlag.AlignCenter: 132>)[source]¶
Align rect with point according to the alignment.
The alignment can be a combination of Qt.AlignmentFlag values.
- autoCropRect(image)[source]¶
Return a QRect specifying the contents of the QImage.
Edges of the image are trimmed if they have the same color.
- oversampleFactor(key, pageSize)[source]¶
Return the optimal scale factor for oversampling.
Oversampling (rendering the image at higher resolution, then downscaling) can help with readability at lower pixel densities.
The pageSize argument specifies the page dimensions in points as returned by page.pageSize().
If this returns 1, render the image directly at your desired size. Otherwise, multiply the page dimensions by the returned value before rendering, then downscale to your desired size.