Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStyleOptionProgressBar looks inactiva on OSX
Forum Updated to NodeBB v4.3 + New Features

QStyleOptionProgressBar looks inactiva on OSX

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chikuba
    wrote on last edited by
    #1

    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;
    
         QApplication::style()->drawControl(QStyle::CE_ProgressBar,
                                            &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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved