hello
why I can't change the color of progressbar ?
Code:
QPalette pal; QList<QProgressBar *> pblist = parent->findChildren<QProgressBar *>(); if(!pblist.isEmpty()){ pal = ouptr->palette(); ouptr->setPalette(pal); ouptr->setValue(50); } }
Printable View
hello
why I can't change the color of progressbar ?
Code:
QPalette pal; QList<QProgressBar *> pblist = parent->findChildren<QProgressBar *>(); if(!pblist.isEmpty()){ pal = ouptr->palette(); ouptr->setPalette(pal); ouptr->setValue(50); } }
Don't know. Your code works perfect on my computer (Linux). You can try style sheets. Why palette is not working on your side could be, that you overwrite it later again? Try a minimal example on your side:Code:
#include <QtCore> #include <QtGui> int main(int argc, char **argv) { QProgressBar pb; pb.setPalette(pal); pb.setValue(50); pb.show(); return app.exec(); }
its default value is green. change Qt::green to Qt::red and test again.
I tested it on WinXP SP2
no,
I even used pb.repaint();
but, it is always green.
WinXP SP2, Qt4.6.2 (2010.02.1)
I guess it has to do with XP style.
Try running your application with different style and see if it works. You simply need to pass "-style <styleName>" to your app.
eg : "app.exe -style motifstyle" [Check the style names for spelling]
Also stylesheets must work on XP. I had used once..
yes
under motifstyle, it run accurately. where is the problem?