Border-Radius is not working with QProgressBar when value is 0.
Solved
QML and Qt Quick
-
wrote on 31 May 2024, 18:47 last edited by
Hello,
I'm using a ProgressBar for a timer but when the Width of the ProgressBar is less than the border-radius, it defaults to no border radius and shows a square.
I tried to do it with a slider instead but that did not work either.
Can I fix it somehow with CSS?
Or maybe there's a workaround with a mask possibly? -
wrote on 1 Jun 2024, 17:56 last edited by
Pasting some working code is always a good idea.
-
wrote on 2 Jun 2024, 11:21 last edited by
@Markkyboy my bad I didn't think it was necessary as It's a known CSS issue
However I fixed it finally by using a Bitmap the same dimensions as the progress bar and setting it as a mask for the progress bar
-
wrote on 2 Jun 2024, 11:32 last edited by
bm = QBitmap(self.min10.size()) bm.fill(Qt.color0) p = QPainter(bm) p.setRenderHint(QPainter.HighQualityAntialiasing) p.setPen(Qt.color1) p.setBrush(Qt.color1) radius = 21 p.drawRoundedRect(QRect(0,0,bm.width(),bm.height()),radius,radius) p.end() self.min10.setMask(bm)
Thanks to a bug report from a decade ago
-
1/4