Feature Request: Expose QPainter methods that accept pointers

Ognyan Moore ognyan.moore at gmail.com
Sat May 7 03:56:49 BST 2022


Hi Phil,

I am one of the maintainers of pyqtgraph, I'd like to request that you
enable some of the function signatures for QPainter methods that accept
pointers.  The following two would be more beneficial for us:

QPainter::drawLines(const QLineF *lines, int lineCount)
QPainter::drawPixmapFragments(const QPainter::PixmapFragment *fragments,
int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints
hints = PixmapFragmentHints())

If it would not be too much trouble, enabling some of the other QPainter
methods that enabled referencing pointers could also be beneficial, but
these won't have the same impact as the ones above

QPainter::drawConvexPolygon(const QPointF *points, int pointCount)
QPainter::drawPoints(const QPointF *points, int pointCount)
QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule
fillRule = Qt::OddEvenFill)
QPainter::drawRects(const QRectF *rectangles, int rectCount)
QPainter::drawPolyline(const QPointF *points, int pointCount)

To demonstrate our usage, I'll highlight what we do with the PySide
bindings.  For the QPainter::drawPixmapFragments we're able to do something
resembling the following

import numpy as np
size = 1_000
arr = np.empty((size, 10), dtype=np.float64)
ptrs = shiboken6.wrapInstance(arr.ctypes.data,
QtGui.QPainter.PixmapFragment)
...
QPainter.drawPixmapFragments(ptrs, size, pixmap)

For the equivalent functionality with PyQt bindings

ptrs = list(map(sip.wrapInstance,
   itertools.count(arr.ctypes.data, arr.strides[0]),
   itertools.repeat(QtGui.QPainter.PixmapFragment, arr.shape[0])))
QPainter.drawPixmapFragments(ptrs[:size], pixmap)


We do this right now with QImage, and in a round-about way with QPolygonF
construction.

Thanks,
Ogi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220506/c2568b7c/attachment.htm>


More information about the PyQt mailing list