1

QStyle サブクラスを使用し、パレットを設定するアプローチは機能しません (ただし、他の基本スタイルに対しては機能します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);
    }
}

OS X でウィジェットの外観を制御する他の方法はありますか? (それとも完全に無理?)

4

1 に答える 1

0

確かに、 QSSを使用できます。 QProgressBar の例を参照してください

于 2012-02-15T06:35:49.330 に答える