Qt-interest Archive, December 2007
Changing QProgressBar colour
Message 1 in thread
I am trying to make a custom progress bar (what inherits from
QProgressBar), I would like to be able to change the colour of the
progress bar fill colour. I have tried to change the colour using the
palette but to no avail. I have pasted some sample code below to show
what I have tried
Any advice would be great.
[ Sample Code ]
QColourProgressBar::QColourProgressBar(QWidget* pkParent)
: QProgressBar(pkParent)
{
QPalette pal = this->palette();
pal.setColor(QPalette::Highlight, QColor("blue"));
pal.setColor(QPalette::Foreground,
QColor("blue"));
pal.setColor(QPalette::Background, QColor("blue"));
pal.setColor(QPalette::Button, QColor("blue"));
this->setPalette(pal);
}
--
[ signature omitted ]
Message 2 in thread
Mike A. Delaney wrote:
> I am trying to make a custom progress bar (what inherits from
> QProgressBar), I would like to be able to change the colour of the
> progress bar fill colour. I have tried to change the colour using the
> palette but to no avail. I have pasted some sample code below to show
> what I have tried
>
> Any advice would be great.
>
> [ Sample Code ]
> QColourProgressBar::QColourProgressBar(QWidget* pkParent)
> : QProgressBar(pkParent)
> {
> QPalette pal = this->palette();
> pal.setColor(QPalette::Highlight, QColor("blue"));
> pal.setColor(QPalette::Foreground,
> QColor("blue"));
> pal.setColor(QPalette::Background, QColor("blue"));
> pal.setColor(QPalette::Button, QColor("blue"));
> this->setPalette(pal);
> }
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
Though I haven't actually tried this for a progress bar, check out style
sheets:
http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qprogressbar
-Rob
--
[ signature omitted ]
Message 3 in thread
Rob Douglas wrote:
> Mike A. Delaney wrote:
>> I am trying to make a custom progress bar (what inherits from
>> QProgressBar), I would like to be able to change the colour of the
>> progress bar fill colour. I have tried to change the colour using the
>> palette but to no avail. I have pasted some sample code below to show
>> what I have tried
>>
>> Any advice would be great.
>>
>> [ Sample Code ]
>> QColourProgressBar::QColourProgressBar(QWidget* pkParent)
>> : QProgressBar(pkParent)
>> {
>> QPalette pal = this->palette();
>> pal.setColor(QPalette::Highlight, QColor("blue"));
>> pal.setColor(QPalette::Foreground,
>> QColor("blue"));
>> pal.setColor(QPalette::Background, QColor("blue"));
>> pal.setColor(QPalette::Button, QColor("blue"));
>> this->setPalette(pal);
>> }
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>
> Though I haven't actually tried this for a progress bar, check out
> style sheets:
> http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qprogressbar
>
>
> -Rob
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
Rob,
Thanks for the links. This gets what I was looking for, kind of seems to be a run around (having to use style sheet) but it gets the job done.
> Mike
--
[ signature omitted ]
Message 4 in thread
> I am trying to make a custom progress bar (what inherits from
> QProgressBar), I would like to be able to change the colour of the
> progress bar fill colour. I have tried to change the colour using the
> palette but to no avail. I have pasted some sample code below to show
> what I have tried
For what it's worth, a few times I've been playing with pallettes in Qt4 on various
widgets and haven't gotten them to work how I expected. For example, changing
background colors on QPushButtons seems to always not be intuitive to what I am
expecting when I sit down to think about it.
To help me, I typically open up Qt Designer, put the widget I'm interested in on the
screen, and then play with its palette via the properties in order to make it look
like what I want. Then I can transcribe the various color roles into the
application without having to go through the guess, compile, guess, compile, steps.
Caleb
--
[ signature omitted ]
Message 5 in thread
Caleb Tennis wrote:
>> I am trying to make a custom progress bar (what inherits from
>> QProgressBar), I would like to be able to change the colour of the
>> progress bar fill colour. I have tried to change the colour using the
>> palette but to no avail. I have pasted some sample code below to show
>> what I have tried
>>
>
> For what it's worth, a few times I've been playing with pallettes in Qt4 on various
> widgets and haven't gotten them to work how I expected. For example, changing
> background colors on QPushButtons seems to always not be intuitive to what I am
> expecting when I sit down to think about it.
>
> To help me, I typically open up Qt Designer, put the widget I'm interested in on the
> screen, and then play with its palette via the properties in order to make it look
> like what I want. Then I can transcribe the various color roles into the
> application without having to go through the guess, compile, guess, compile, steps.
>
> Caleb
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
Caleb,
Thanks for the tip but when it comes to the QProgressBar chunk data, I
could never seem to get the designer application to reflect the colour
changes. I tried to change the colour programmatically to try to rule
out a bug in the designer but it looks like the palette just don't
change the chunk colour of the QProgressBar
-- Mike
--
[ signature omitted ]