QStyleOptionProgressBar looks inactiva on OSX

  • Hi

    Been trying for a few weeks now to fix my progress bar in osx. In windows it looks green and nice but in osx it's a plain gray color and you cant really tell the colors apart (which is a huge issue). This is what I'm doing at the moment;

    First I have a workspace (widget) which is a sidview of the MainWindow. In the workspace I create a QTableView and to the following to it;

    @_tableView->setItemDelegate(new ProgressBarDelegate);@

    My ProgressBarDelegate looks like this:

    @#include "progressbardelegate.h"

    ProgressBarDelegate::ProgressBarDelegate(QObject *parent) : QStyledItemDelegate(parent) {}

    void ProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {

    if(index.column() == 2) {
         int progressPercentage = index.model()->data(index, Qt::DisplayRole).toInt();
         QStyleOptionProgressBarV2 progressBarOption;
         progressBarOption.rect = QRect(option.rect.x(), option.rect.y() + 5 , option.rect.width(), option.rect.height() / 1.5);
         progressBarOption.minimum = 0;
         progressBarOption.maximum = 100;
         progressBarOption.progress = progressPercentage;
                                            &progressBarOption, painter);
     } else QStyledItemDelegate::paint(painter, option, index);


    I've been trying some different aproaches:

    @QPalette pal = progressBarOption.palette;
    QColor col = QColor(35, 35,25);
    pal.setColor(QPalette::Highlight, col); // or ::window
    progressBarOption.palette = pal; @

    Also tried to use stylesheets but they only change progressbars that I init using "QProgressBar", not this one. I havn't found any info about how to actaully change the color of a QStyleOptionProgressBar.

    Could I do the same thing using QItemDelegate? At the moment, ANY solution would do, aslong as I get a progressbar that is NOT gray on every row. I am completly stuck and this is pretty much the last thing I have to do on our app. I would really appricate your help.

Log in to reply

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