<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Cool QProgressBar Stylesheet</title>
	<atom:link href="http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/</link>
	<description>Your blog is probably better than mine.</description>
	<lastBuildDate>Tue, 07 Sep 2010 02:05:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: tom</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-104325</link>
		<dc:creator>tom</dc:creator>
		<pubDate>Fri, 09 Jul 2010 02:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-104325</guid>
		<description>Hi Dave,

i realised i never got back to you,

yes the code wise changing of the colour-slider worked. just needed to calculate the right blend 

it&#039;s in pyqt, but should be easy to read:

note slider is horizontal with a min value of 0 and max = 20.


            int inValue = getValueFromHeater();
            self.heatProgressBar.setValue(inValue)
            
            # make the slider show blue to red from left to right
            if( inValue &gt;= 0 ):
                percentage = inValue * 0xFF / 20

                #calculate the blend                
                redTo = str(hex(percentage))
                redTo = redTo.replace(&#039;0x&#039;, &#039;&#039;)
                if( len(redTo) &lt;2 ):
                    redTo = &quot;0&quot; + redTo
                blueTo = str(hex(0xFF-percentage))
                blueTo = blueTo.replace(&#039;0x&#039;, &#039;&#039;)
                if( len(blueTo) &lt;2 ):
                    blueTo = &quot;0&quot; + blueTo
                if( inValue == 20):
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 4px; border-bottom-left-radius: 4px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)
                else:
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 4px; border-bottom-left-radius: 4px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)
                if( inValue == 1):
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 3px; border-bottom-left-radius: 3px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)
                self.heatProgressBar.setStyleSheet(QtGui.QApplication.translate(&quot;Form&quot;, astyle, None, QtGui.QApplication.UnicodeUTF8));


thanks for you suggestion !
cheers,
tom</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>i realised i never got back to you,</p>
<p>yes the code wise changing of the colour-slider worked. just needed to calculate the right blend </p>
<p>it&#8217;s in pyqt, but should be easy to read:</p>
<p>note slider is horizontal with a min value of 0 and max = 20.</p>
<p>            int inValue = getValueFromHeater();<br />
            self.heatProgressBar.setValue(inValue)</p>
<p>            # make the slider show blue to red from left to right<br />
            if( inValue &gt;= 0 ):<br />
                percentage = inValue * 0xFF / 20</p>
<p>                #calculate the blend<br />
                redTo = str(hex(percentage))<br />
                redTo = redTo.replace(&#8217;0x&#8217;, &#8221;)<br />
                if( len(redTo) &lt;2 ):<br />
                    redTo = &quot;0&quot; + redTo<br />
                blueTo = str(hex(0xFF-percentage))<br />
                blueTo = blueTo.replace(&#039;0x&#039;, &#039;&#039;)<br />
                if( len(blueTo) &lt;2 ):<br />
                    blueTo = &quot;0&quot; + blueTo<br />
                if( inValue == 20):<br />
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 4px; border-bottom-left-radius: 4px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)<br />
                else:<br />
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 4px; border-bottom-left-radius: 4px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)<br />
                if( inValue == 1):<br />
                    astyle = &quot;QProgressBar {background-image: url(:/IVD/images/transparent.png); border: 2px solid white; border-radius: 8px; } QProgressBar::chunk:horizontal { border-top-left-radius: 3px; border-bottom-left-radius: 3px; border: 1px ; background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0000FF, stop: 1 #%s00%s ); }&quot; % (redTo, blueTo)<br />
                self.heatProgressBar.setStyleSheet(QtGui.QApplication.translate(&quot;Form&quot;, astyle, None, QtGui.QApplication.UnicodeUTF8));</p>
<p>thanks for you suggestion !<br />
cheers,<br />
tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BA</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-95971</link>
		<dc:creator>BA</dc:creator>
		<pubDate>Mon, 21 Dec 2009 22:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-95971</guid>
		<description>nevermind, found the issue. it was a small typo in my CSS.

QProgressBar::chunk:disabled is correct</description>
		<content:encoded><![CDATA[<p>nevermind, found the issue. it was a small typo in my CSS.</p>
<p>QProgressBar::chunk:disabled is correct</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-95855</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 19 Dec 2009 21:50:48 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-95855</guid>
		<description>BA, have you tried QProgressBar:disabled::chunk?</description>
		<content:encoded><![CDATA[<p>BA, have you tried QProgressBar:disabled::chunk?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BA</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-95780</link>
		<dc:creator>BA</dc:creator>
		<pubDate>Sat, 19 Dec 2009 00:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-95780</guid>
		<description>Just wondering if you know how to set the style of a progress bar when it&#039;s disabled? I&#039;ve tried QProgressBar::chunk:disabled but that doesn&#039;t seem to work</description>
		<content:encoded><![CDATA[<p>Just wondering if you know how to set the style of a progress bar when it&#8217;s disabled? I&#8217;ve tried QProgressBar::chunk:disabled but that doesn&#8217;t seem to work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe D.</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-94330</link>
		<dc:creator>Joe D.</dc:creator>
		<pubDate>Mon, 30 Nov 2009 22:42:15 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-94330</guid>
		<description>Hey Dave...I worked with you via correspondence at your previous gig and just wanted to wish you the best; I was just googling for any tricks to display greater than 100% in a QProgressBar (not looking very likely without subclassing) and noticed your blog came up near the top of the 2nd page of my results; congrats!</description>
		<content:encoded><![CDATA[<p>Hey Dave&#8230;I worked with you via correspondence at your previous gig and just wanted to wish you the best; I was just googling for any tricks to display greater than 100% in a QProgressBar (not looking very likely without subclassing) and noticed your blog came up near the top of the 2nd page of my results; congrats!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-92546</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 13 Nov 2009 04:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-92546</guid>
		<description>Tom,

I believe that is not possible. You could do it, but you&#039;d have to do it in your C++ code and update your stylesheet after each progress update using setStyleSheet().

Let me know what you find out!

--Dave</description>
		<content:encoded><![CDATA[<p>Tom,</p>
<p>I believe that is not possible. You could do it, but you&#8217;d have to do it in your C++ code and update your stylesheet after each progress update using setStyleSheet().</p>
<p>Let me know what you find out!</p>
<p>&#8211;Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tom</title>
		<link>http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/comment-page-1/#comment-92545</link>
		<dc:creator>tom</dc:creator>
		<pubDate>Fri, 13 Nov 2009 04:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=509#comment-92545</guid>
		<description>thanks dave, 

that is looking very cool.

would you know if it is possible to make a gradient for the slider that starts at one color (for example blue for cool)
and as you increase the slider it will show a gradient that slowly goes to red.

if i try it just shows the blue to red gradient scaled to the little bit of the progress bar that is visible.

no worries if you don&#039;t or can&#039;t answer, just thought i&#039;d ask.

cheers,
tom

my try for a horizontal slider:

QProgressBar {
border: 1px solid black;
text-align: top;
padding: 1px;
border-top-left-radius: 7px;
border-bottom-left-radius: 7px;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #fff,
stop: 0.4999 #eee,
stop: 0.5 #ddd,
stop: 1 #eee );
width: 15px;
}
QProgressBar::chunk {
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,
stop: 0 #0000ff,
stop: 1 #ff0000 );
border-top-left-radius: 7px;
border-bottom-left-radius: 7px;
border: 1px solid black;
}

but as you can see it shows [blue--&gt;Red&#124;        ] on a half full slider
where i would expect to see[ blue--&gt;purple     ] 
and only see                      [blue----------&gt;red] when the value is 100%</description>
		<content:encoded><![CDATA[<p>thanks dave, </p>
<p>that is looking very cool.</p>
<p>would you know if it is possible to make a gradient for the slider that starts at one color (for example blue for cool)<br />
and as you increase the slider it will show a gradient that slowly goes to red.</p>
<p>if i try it just shows the blue to red gradient scaled to the little bit of the progress bar that is visible.</p>
<p>no worries if you don&#8217;t or can&#8217;t answer, just thought i&#8217;d ask.</p>
<p>cheers,<br />
tom</p>
<p>my try for a horizontal slider:</p>
<p>QProgressBar {<br />
border: 1px solid black;<br />
text-align: top;<br />
padding: 1px;<br />
border-top-left-radius: 7px;<br />
border-bottom-left-radius: 7px;<br />
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,<br />
stop: 0 #fff,<br />
stop: 0.4999 #eee,<br />
stop: 0.5 #ddd,<br />
stop: 1 #eee );<br />
width: 15px;<br />
}<br />
QProgressBar::chunk {<br />
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,<br />
stop: 0 #0000ff,<br />
stop: 1 #ff0000 );<br />
border-top-left-radius: 7px;<br />
border-bottom-left-radius: 7px;<br />
border: 1px solid black;<br />
}</p>
<p>but as you can see it shows [blue--&gt;Red|        ] on a half full slider<br />
where i would expect to see[ blue--&gt;purple     ]<br />
and only see                      [blue----------&gt;red] when the value is 100%</p>
]]></content:encoded>
	</item>
</channel>
</rss>
