Custom-painted progress bar with rock-solid pill ends. More...
| Header: | #include <PillProgressBar> |
| Inherits: | QProgressBar |
Qt6 QSS on QProgressBar runs into two corner-rounding bugs: the chunk's corners are computed relative to its own rect rather than the bar's clip path (so at partial fill the chunk's right edge sits a pixel or two inside the bar's curve), and at certain bar widths the platform style leaks through and paints a flat left edge over the QSS-rounded outline. Both manifested as the pill silhouette breaking the moment any content was drawn into the chunk.
This class skips the stylesheet entirely. paintEvent draws a clipped rounded rect with QPainter + QPainterPath:
1. Build the pill QPainterPath at half-height radius. 2. Fill it with the background colour. 3. Clip to the pill, fill the chunk rect (a flat-left, flat-right rectangle inside the clip), so the chunk's edges curve to match the bar's outline at left and right by virtue of the clip, not by the chunk having its own corner radius. 4. Draw the outline path with a pen. 5. Draw the QProgressBar::text() centred.
The pill is preserved at any value and any width.