Increase QPen Width

556 views Asked by At

I need to increase the pen width for the below code using Painter/QPen, but nothing that I try works. Can someone please point me in the right direction?

    while c_len < MAX_LENGTH:
        # Set the pen color for this segment
        sat = 200 * (MAX_LENGTH - c_len) / MAX_LENGTH
        hue = (color + 130 * (height - y_s) / height) % 360
        p.setPen(QPen(QColor_HSV(hue, sat, 255, 20), 2))
1

There are 1 answers

0
MiaPlan.de On

You can use the setWidth method of QPen like so:

while c_len < MAX_LENGTH:
    # Set the pen color for this segment
    sat = 200 * (MAX_LENGTH - c_len) / MAX_LENGTH
    hue = (color + 130 * (height - y_s) / height) % 360
    pen = QPen(QColor_HSV(hue, sat, 255, 20))
    pen.setWidth(2)
    p.setPen(pen)

Just giving the value 2 to the constructor does not work, because there is no matching signature for your arguments.

As an alternative, use arguments that are supported by the signature:

pen = QPen(QColor_HSV(hue, sat, 255, 20), 2, QtCore.Qt.SolidLine)

This is preferred, as it avoids a separate function call which is slow in Python.