[Solved] PixelMetric for QProgressBar gutter/margin spacing?
-
I have a subclass of QProgressBar that can go both positive and negative (with zero at the center). I overrode paintEvent() so that it can draw itself, and I draw the groove (QStyle::CE_ProgressBarGroove) separately from the bar concents (QStyle::CE_ProgressBarContents).
When drawing the bar, I have been setting its dimensions to go all the way to the edge of the groove, but apparently this is not correct for some styles. See the bottom progress bars in this screenshot:
!http://i.imgur.com/zLd41pX.png(screenshot)!The bar is apparently supposed to be drawn with a margin depending on the graphical style in use at the time. What is the correct way to draw the bar contents so that it will look correct with all styles? Is there a PixelMetric value for the spacing?
EDIT: anda_skoa over at QtCentre pointed out that calling style()->subElementRect() with SE_ProgressBarContents will calculate the bounding rectangle for the bar with the active style. This works well, and there's no need for manipulating the bar with PixelMetrics.
--Colin