Unable to change progress bar background color [SOLVED]



  • I tried this as per documentation, but it didn't work:
    @ui->progressBar->setStyleSheet("background-color: #05B8CC;width: 20px;");@


  • Moderators

    your code is working on ubuntu, plastique style.(and others, you can try it out using the preview in Qt Creator)

    I guess you are on windows? It's the windows style that prevents it then.

    Have a look at the " style sheet" example. That's a good way of testing al your stylesheets out.



  • I also use Ubuntu (Gnome3 gtk+). I tried again with a simple form having just a progress bar, but no change.
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    ui->progressBar->setStyleSheet("background-color: yellow");
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }@


  • Moderators

    did you try it out using plastique style?

    As I mentioned it's the style preventing stylesheets to make changes. I guess you will need to make your own style.



  • I tried plastique style also but no effect. Isn't there any other alternative, nevertheless thanks!



  • It is working in style sheets example but not otherwise, i need to look into it. Is there anything wrong in my syntax



  • Yes it worked at last, but not with GTK+. Most probably it’s the GTK+ style preventing stylesheets to make changes as my system style is also GTK+


  • Moderators

    If changing the used style is ok for you then it's solved? AFAIK GTK+ style is like windows style preventing stylesheet changes on some parts.

    Could you please edit your first post and add [solved] in the title?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.