void paintEvent(QPaintEvent* e) { QPainter p(this); p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); QLinearGradient lightLinearGrad; lightLinearGrad.setSpread(QGradient::PadSpread); lightLinearGrad.setStart(x(), 0); lightLinearGrad.setFinalStop(x(), height()); p.setPen(Qt::NoPen); lightLinearGrad.setColorAt(0, QColor(248, 248, 248, 248)); lightLinearGrad.setColorAt(1, QColor(255, 255, 255, 0)); // QPainterPath path; p.setBrush(QBrush(lightLinearGrad)); p.drawRect(this->rect()); }
QLinearGradient 绘制渐变效果
最新推荐文章于 2024-08-01 17:53:30 发布