draw qrcode with fixed framesize
This commit is contained in:
@@ -66,16 +66,15 @@ class QRCodeWidget(QWidget):
|
|||||||
framesize = min(r.width(), r.height())
|
framesize = min(r.width(), r.height())
|
||||||
boxsize = int( (framesize - 2*margin)/k )
|
boxsize = int( (framesize - 2*margin)/k )
|
||||||
size = k*boxsize
|
size = k*boxsize
|
||||||
left = (r.width() - size)/2
|
left = (framesize - size)/2
|
||||||
top = (r.height() - size)/2
|
top = (framesize - size)/2
|
||||||
|
# Draw white background with margin
|
||||||
# Make a white margin around the QR in case of dark theme use
|
|
||||||
qp.setBrush(white)
|
qp.setBrush(white)
|
||||||
qp.setPen(white)
|
qp.setPen(white)
|
||||||
qp.drawRect(left-margin, top-margin, size+(margin*2), size+(margin*2))
|
qp.drawRect(0, 0, framesize, framesize)
|
||||||
|
# Draw qr code
|
||||||
qp.setBrush(black)
|
qp.setBrush(black)
|
||||||
qp.setPen(black)
|
qp.setPen(black)
|
||||||
|
|
||||||
for r in range(k):
|
for r in range(k):
|
||||||
for c in range(k):
|
for c in range(k):
|
||||||
if matrix[r][c]:
|
if matrix[r][c]:
|
||||||
|
|||||||
Reference in New Issue
Block a user