QWidget可以设置QStyle,它可以绘制很多东西(具体内容没研究,待续)

QStyle * QWidget::style() const

See also QWidget::setStyle(), QApplication::setStyle(), and QApplication::style().

它可以绘制很多东西,比如设置背景色:

void CustomWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

http://doc.qt.io/qt-4.8/qstyle.html

原文地址:https://www.cnblogs.com/findumars/p/5702160.html