+ Reply to Thread
Results 1 to 4 of 4

Thread: Bi-directional QProgressBar, drawn from the center?

  1. #1
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Bi-directional QProgressBar, drawn from the center?

    Is it possible to configure the QProgressBar (or some similar widget) to display a bar that extends out from the center (rather than from one end)? For example, with a range from -100 to 100, I'd like a value of -50 to display a bar that extends from the midpoint, halfway to the left-hand side. A value of zero would display no bar at all.

    Is there an existing control that would do this, or would it require a custom widget?

    --Colin

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,323
    Thanks
    19
    Thanked 918 Times in 876 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Bi-directional QProgressBar, drawn from the center?

    I am not aware of such a widget. But you can simply subclass QProgressBar and overwrite the paint method. By using QStyledPainter or QStyle direct, you can even make the widget style aware.
    New version of Artistic Style Plugin (1.1.0) for Qt Creator 2.7.0. Check it out: http://astyleplugin.sourceforge.net.

  3. #3
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Bi-directional QProgressBar, drawn from the center?

    What is the best way to draw the filled, rounded rectangle that is normally drawn by CE_ProgressBarContents? Do I need to use QStylePainter::drawRoundRect() and then somehow fill it to to match the style? (The style I normally use has light- and dark-blue stripes in the progress bar fill.)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,323
    Thanks
    19
    Thanked 918 Times in 876 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Bi-directional QProgressBar, drawn from the center?

    the best way is to draw it with CE_ProgressBarContents! Use QStyle::drawControl() and just alter QStyleOption with the rectangle you want.
    New version of Artistic Style Plugin (1.1.0) for Qt Creator 2.7.0. Check it out: http://astyleplugin.sourceforge.net.

  5. The following user says thank you to Lykurg for this useful post:

    cmb (13th May 2012)

+ Reply to Thread

Similar Threads

  1. Bi-directional Lookup Table
    By premroxx in forum Newbie
    Replies: 1
    Last Post: 21st April 2012, 22:15
  2. QPainter::drawText - nothing drawn
    By Vit Stepanek in forum Qt Programming
    Replies: 6
    Last Post: 23rd November 2010, 18:54
  3. How to get colour of already drawn pixel?
    By iksarp in forum Newbie
    Replies: 2
    Last Post: 16th March 2010, 11:50
  4. Can you change which widgets are drawn on top?
    By Spectralist in forum Newbie
    Replies: 4
    Last Post: 6th December 2009, 18:31
  5. QGraphicsItem is not drawn again?
    By zgulser in forum Qt Programming
    Replies: 12
    Last Post: 19th October 2009, 16:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts