Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] PixelMetric for QProgressBar gutter/margin spacing?

[Solved] PixelMetric for QProgressBar gutter/margin spacing?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 457 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    colinb
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved