1

The approach using a QStyle Subclass, and setting the palette doesn't work (but does work for other base styles to MyStyle).

void MyStyle::drawControl(ControlElement control, const QStyleOption *option,
                          QPainter *painter, const QWidget *widget) const
{    
    switch(control) 
    {
        case CE_ProgressBar: 
        {
            const QStyleOptionProgressBarV2 * pOpts =
            static_cast<const QStyleOptionProgressBarV2 *>(option);
            QStyleOptionProgressBarV2 oOpts(*pOpts);

            QColor progressColor(QColor::fromHsl(50, 160, 162));
            oOpts.palette.setColor(QPalette::Highlight, progressColor);

            // BASESTYLE is QMacStyle
            BASESTYLE::drawControl(control, &outputOptions, painter, widget);
        }
            break;

        default:
            BASESTYLE::drawControl(control, option, painter, widget);
    }
}

Is there some other way to control the appearance of widgets under OS X? (Or is it completely impossible?)

James
  • 24,676
  • 13
  • 84
  • 130
  • What do you get if you comment out all of the code in the CE_ProgressBar case? Does the QProgressBar then draw nothing/garbage only? If so, that would indicate that you are on the right track, but BASESTYLE::drawControl)( is ignoring your preamble. – Jeremy Friesner Dec 17 '11 at 02:11
  • Yeah I can confirm that if `BASESTYLE::drawControl()` in the `CE_ProgressBar` case is removed, then no progress bar is drawn. (`BASESTYLE` is, of course, `QMacStyle`). – James Dec 17 '11 at 12:37
  • In the worst case you could always copy-and-paste the code from BASESTYLE::drawControl() into your own method, and then modify it to taste... but there may be a more elegant method than that. You'll have to look at the source code for BASESTYLE::drawControl() and see how the CE_ProgressBar case is implemented, and that should give you some ideas about what influence you can have on its behavior. – Jeremy Friesner Dec 17 '11 at 16:45
  • Committing the crime of using a cross platform UI framework on a Mac takes away from you the right to be concerned with style ;) – Nikolai Ruhe Feb 15 '12 at 07:02

1 Answers1

0

Sure, you can use QSS, see QProgressBar example

Dmitriy
  • 5,357
  • 8
  • 45
  • 57