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¶
- class MapToPage(transform)[source]¶
Bases:
object
Simple class wrapping a QTransform to map rect and point to page coordinates.
- class MapFromPage(transform)[source]¶
Bases:
MapToPage
Simple class wrapping a QTransform to map rect and point from page to 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
- 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. Therotation
is 0, 1, 2 or 3, etc. (Rotate_0
,Rotate_90
, etc…). Ifdest
is True,width
andheight
refer 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.