当前位置: 首页>>代码示例>>C++>>正文


C++ QLinearGradient类代码示例

本文整理汇总了C++中QLinearGradient的典型用法代码示例。如果您正苦于以下问题:C++ QLinearGradient类的具体用法?C++ QLinearGradient怎么用?C++ QLinearGradient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QLinearGradient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PremierPoint

/**
 * Décrit le façon de dessiner l'élément sur la scène
 *
 * @brief   Item_Rout::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget)
 * @param   pPainter    le pinceau servant à dessiner sur la scène
 * @param   option      Option sur le dessin (pas utile dans notre cas)
 * @param   widget      Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas)
 * @see     Item
 */
void Item_Rout::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    this->GererSelection(pPainter) ;
    this->sTexte = this->pInstRepresentee->toString() ;

    //Définition du dégradé
    qreal           top             (this->rect.top()) ;
    qreal           left            (this->rect.left()) ;
    QPointF         PremierPoint    (0, top) ;
    QPointF         SecondPoint     (0, -top) ;
    QLinearGradient grad            (PremierPoint, SecondPoint) ;
    QColor          PremiereCouleur (0xFF, 0xD5, 0x98, 0xFF) ;
    QColor          SecondeCouleur  (0xF3, 0xA6, 0x62, 0xFF) ;
    grad.setColorAt(0, PremiereCouleur);
    grad.setColorAt(1, SecondeCouleur);

    //Définition du brush
    QBrush brush(grad);
    pPainter->setBrush(brush);

    //Dessin de l'item
    QPointF OriginePrem (left*(7.0/8.0), top) ;
    QPointF FinPrem     (left*(7.0/8.0), -top) ;
    QPointF OrigineSec  (-left*(7.0/8.0), top) ;
    QPointF FinSec      (-left*(7.0/8.0), -top) ;
    pPainter->drawRect(rect);
    pPainter->drawLine(OriginePrem, FinPrem);
    pPainter->drawLine(OrigineSec, FinSec);

    pPainter->setPen(QPen());
    pPainter->drawText(rect, sTexte, QTextOption(Qt::AlignCenter));
}
开发者ID:lna44700,项目名称:openorganigram,代码行数:41,代码来源:Item_Rout.cpp

示例2: fg

void KisGradientBenchmark::benchmarkGradient()
{
    KoColor fg(m_colorSpace);
    KoColor bg(m_colorSpace);
    fg.fromQColor(Qt::blue);
    bg.fromQColor(Qt::black);
    
    QBENCHMARK
    {
        QLinearGradient grad;
        grad.setColorAt(0, Qt::white);
        grad.setColorAt(1.0, Qt::red);
        KoAbstractGradient* kograd = KoStopGradient::fromQGradient(&grad);
        Q_ASSERT(kograd);
        KisGradientPainter fillPainter(m_device);
        //setupPainter(&fillPainter);
        fillPainter.setGradient(kograd);

        fillPainter.beginTransaction(kundo2_noi18n("Gradient Fill"));

        //fillPainter.setProgress(updater->startSubtask());
        fillPainter.setOpacity(OPACITY_OPAQUE_U8);
        // default
        fillPainter.setCompositeOp(COMPOSITE_OVER);
        fillPainter.setGradientShape(KisGradientPainter::GradientShapeBiLinear);
        fillPainter.paintGradient(QPointF(0,0), QPointF(3000,3000), KisGradientPainter::GradientRepeatNone, true, false, 0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT);

        fillPainter.deleteTransaction();
    }
    
    // uncomment this to see the output
    QImage out = m_device->convertToQImage(m_colorSpace->profile(),0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT);
    out.save("fill_output.png");
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:34,代码来源:kis_gradient_benchmark.cpp

示例3: QBrush

        void GraphWidget::_drawLines()
        {
			int width = this->widget->width();
			int height = this->widget->height();
			QList<float>::iterator it = this->_values.begin();
			QList<float>::iterator itEnd = --this->_values.end();
			this->_painter.fillRect(this->_image.rect(), QBrush(Qt::white));
			QPainterPath path;
			int pos = width - this->_values.size();
			while (pos < 0)
			{
				this->_values.removeLast();
				pos = width - this->_values.size();
			}
			path.moveTo(pos, height);
            for (; it != itEnd && width > pos; --itEnd, ++pos)
				path.lineTo(pos, height - static_cast<int>(*itEnd * height / this->_highest_value));
			path.lineTo(pos, height - static_cast<int>(*itEnd * height / this->_highest_value));
			path.lineTo(pos + height, height);
			path.closeSubpath();

			QLinearGradient grad;
			grad.setColorAt(0, QColor(0, 250, 0));
			grad.setColorAt(1, QColor(0, 75, 0));
			grad.setStart(0, 0);
			grad.setFinalStop(0, height);
			this->_painter.setBrush(QBrush(grad));
			this->_painter.drawPath(path);
        }
开发者ID:hotgloupi,项目名称:zhttpd,代码行数:29,代码来源:GraphWidget.cpp

示例4: setupCustomPlot

void MainWindow::setupCustomPlot()
{
    ui->customplot->xAxis->setRange(LEFTBOUND, RIGHTBOUND);
    ui->customplot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    ui->customplot->axisRect()->setRangeDrag(Qt::Horizontal | Qt::Vertical);

    //backgroundcolor
    QLinearGradient plotGrad;
    plotGrad.setStart(0,0);
    plotGrad.setFinalStop(0,350);
    plotGrad.setColorAt(0,QColor(80,80,80));
    plotGrad.setColorAt(1,QColor(50,50,50));
    ui->customplot->setBackground(plotGrad);
    //

    ui->customplot->xAxis->setBasePen(QPen(Qt::white, 1));
    ui->customplot->yAxis->setBasePen(QPen(Qt::white, 1));
    ui->customplot->xAxis->setTickPen(QPen(Qt::white, 1));
    ui->customplot->yAxis->setTickPen(QPen(Qt::white, 1));
    ui->customplot->xAxis->setSubTickPen(QPen(Qt::white, 1));
    ui->customplot->yAxis->setSubTickPen(QPen(Qt::white, 1));
    ui->customplot->xAxis->setTickLabelColor(Qt::white);
    ui->customplot->yAxis->setTickLabelColor(Qt::white);

    ui->customplot->xAxis->grid()->setPen(QPen(QColor(140,140,140), 1, Qt::DotLine));
    ui->customplot->yAxis->grid()->setPen(QPen(QColor(140,140,140), 1, Qt::DotLine));
    ui->customplot->xAxis->grid()->setSubGridPen(QPen(QColor(80,80,80), 1, Qt::DotLine));
    ui->customplot->yAxis->grid()->setSubGridPen(QPen(QColor(80,80,80), 1, Qt::DotLine));
    ui->customplot->xAxis->grid()->setSubGridVisible(true);
    ui->customplot->yAxis->grid()->setSubGridVisible(true);

    ui->customplot->xAxis->setLabelColor(Qt::white);
    ui->customplot->yAxis->setLabelColor(Qt::white);
}
开发者ID:sandyre,项目名称:ifmo_course2,代码行数:34,代码来源:mainwindow.cpp

示例5: getLinearGradient

QLinearGradient* getLinearGradient(const CLLinearGradient* linear, const CLBoundingBox* bounds, const CLRenderResolver* resolver)
{
  double x1 = bounds->getPosition().getX() + linear->getXPoint1().getAbsoluteValue()  + (linear->getXPoint1().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth());
  double y1 = bounds->getPosition().getY() + linear->getYPoint1().getAbsoluteValue()  + (linear->getYPoint1().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight());
  double x2 = bounds->getPosition().getX() + linear->getXPoint2().getAbsoluteValue()  + (linear->getXPoint2().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth());
  double y2 = bounds->getPosition().getY() + linear->getYPoint2().getAbsoluteValue()  + (linear->getYPoint2().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight());

  QLinearGradient* result = new QLinearGradient(x1, y1, x2, y2);

  switch (linear->getSpreadMethod())
    {
      case CLGradientBase::REFLECT:
        result->setSpread(QGradient::ReflectSpread);
        break;

      case CLGradientBase::REPEAT:
        result->setSpread(QGradient::RepeatSpread);
        break;

      case CLGradientBase::PAD:
        result->setSpread(QGradient::PadSpread);
        break;

      default:
        break;
    }

  for (size_t i = 0; i < linear->getNumGradientStops(); ++i)
    {
      const CLGradientStop* stop = linear->getGradientStop(i);
      result->setColorAt(stop->getOffset().getAbsoluteValue() + stop->getOffset().getRelativeValue() / 100.0, getColor(stop->getStopColor(), resolver));
    }

  return result;
}
开发者ID:sachiinb,项目名称:COPASI,代码行数:35,代码来源:qrenderconverter.cpp

示例6: couleur

//---------------------------------------------------------------
void LonLatGrid::drawLabel(QPainter &pnt, const Projection *proj,
				double value, int i, int j)
{
    int   a,b,c,d;
    QString label;
	QColor couleur(10,10,10);

    label = label.sprintf("%g", value);

    QPen penText(couleur);
    QFont fontText = Font::getFont(FONT_LonLatGridLabel);
    QFontMetrics fmet(fontText);
    QRect rect = fmet.boundingRect(label);
    pnt.setPen(penText);
    pnt.setFont(fontText);

	// use a gradient, because it's a bug sometimes with solid pattern (black background)
	QLinearGradient gradient;
    int r = 255;
	gradient.setColorAt(0, QColor(r,r,r, 170));
	gradient.setColorAt(1, QColor(r,r,r, 170));
    pnt.setBrush(gradient);

    //---------------------------------------------------------
    // Ecrit le label
    //---------------------------------------------------------
	
// 	rect = fmet.boundingRect(label);
// 	rect.moveTo((a+c)/2-rect.width()/2, (b+d)/2-rect.height()/2);
// 	pnt.drawRect(rect.x()-1, rect.y(), rect.width()+2, fmet.ascent()+2);
// 	pnt.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter, label);

}
开发者ID:prohan91,项目名称:zyGrib,代码行数:34,代码来源:LonLatGrid.cpp

示例7: qMax

void PlaylistItemDelegate::paintActiveOverlay(QPainter *painter, const QRect &line) const {
    static QLinearGradient linearGradient;
    static bool initialized = false;

    if (!initialized) {
        QPalette palette;
        QColor highlightColor = palette.color(QPalette::Highlight);
        QColor backgroundColor = palette.color(QPalette::Base);
        const float animation = 0.4;
        const int gradientRange = 16;

        QColor color2 = QColor::fromHsv(
                    highlightColor.hue(),
                    (int) (backgroundColor.saturation() * (1.0f - animation) + highlightColor.saturation() * animation),
                    (int) (backgroundColor.value() * (1.0f - animation) + highlightColor.value() * animation)
                    );
        QColor color1 = QColor::fromHsv(
                    color2.hue(),
                    qMax(color2.saturation() - gradientRange, 0),
                    qMin(color2.value() + gradientRange, 255)
                    );

        linearGradient = QLinearGradient(0, 0, 0, THUMB_HEIGHT);
        linearGradient.setColorAt(0.0, color1);
        linearGradient.setColorAt(1.0, color2);
        initialized = true;
    }

    painter->fillRect(line, linearGradient);
}
开发者ID:dairdev,项目名称:minitube,代码行数:30,代码来源:playlistitemdelegate.cpp

示例8: enableInterpModel

void SurfaceGraph::enableInterpModel(bool enable)
{
    if (enable){
        this->nn=n;
        this->mm=m;
        m_InterpSeries->setDrawMode(QSurface3DSeries::DrawSurfaceAndWireframe);
        m_InterpSeries->setFlatShadingEnabled(true);
        m_graph->axisX()->setLabelFormat("%.2f");
        m_graph->axisZ()->setLabelFormat("%.2f");
        m_graph->axisX()->setRange(xMin, xMax);
        m_graph->axisY()->setAutoAdjustRange(true);
        m_graph->axisZ()->setRange(zMin, zMax);
        m_graph->axisX()->setLabelAutoRotation(30);
        m_graph->axisY()->setLabelAutoRotation(90);
        m_graph->axisZ()->setLabelAutoRotation(30);
        m_graph->removeSeries(m_InterpSeries);
        m_graph->removeSeries(m_InitPlotSeries);
        m_graph->removeSeries(m_ResidSeries);
        m_graph->addSeries(m_InterpSeries);
        m_graph->activeTheme()->setType(Q3DTheme::ThemePrimaryColors);
        QLinearGradient gr;
        gr.setColorAt(0.0, Qt::green);
        m_graph->seriesList().at(0)->setBaseGradient(gr);
        m_graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
        m_rangeMinX=xMin;
        m_rangeMinZ=zMin;
        m_stepX=(xMax-xMin)/double(skolkoX-1);
        m_stepZ=(zMax-zMin)/double(skolkoZ-1);
        kolichestvo=1;
    }
}
开发者ID:tetris0k,项目名称:Univercity-projects,代码行数:31,代码来源:surfacegraph.cpp

示例9: PremierPoint

/**
 * Décrit le façon de dessiner l'élément sur la scène
 *
 * @brief   Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget)
 * @param   pPainter    le pinceau servant à dessiner sur la scène
 * @param   option      Option sur le dessin (pas utile dans notre cas)
 * @param   widget      Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas)
 * @see     Item
 */
void Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
    this->GererSelection(pPainter) ;
    this->sTexte = this->pInstRepresentee->toString() ;

    //Définition du dégradé dans l'item
    qreal           top             (this->rect.top()) ;
    QPointF         PremierPoint    (0, top) ;
    QPointF         SecondPoint     (0, -top) ;
    QLinearGradient grad            (PremierPoint, SecondPoint) ;
    QColor          PremiereCouleur (0x98, 0xFE, 0x98, 0xFF) ;
    QColor          SecondeCouleur  (0x62, 0xBA, 0x62, 0xFF) ;
    grad.setColorAt(0, PremiereCouleur) ;
    grad.setColorAt(1, SecondeCouleur) ;

    //Définition du brush pour appliquer le dégradé
    QBrush brush    (grad) ;

    //Dessin de l'item
    pPainter->setBrush(brush);
    pPainter->drawRect(rect);

    pPainter->setPen(QPen());
    pPainter->drawText(rect, sTexte, QTextOption(Qt::AlignCenter));
}
开发者ID:lna44700,项目名称:openorganigram,代码行数:34,代码来源:Item_Ope.cpp

示例10: gradient

void ViewProfileScale::paintHue ()
{
  // Create two spectrums:
  // 1) one spectrum from red to green
  // 2) another from green to blue
  QLinearGradient gradient (QPointF (0.0,
                                     height() / 2.0),
                            QPointF (width (),
                                     height () / 2.0));
  gradient.setColorAt (0.0000, Qt::red);
  gradient.setColorAt (0.3333, Qt::green);
  gradient.setColorAt (0.6666, Qt::blue);
  gradient.setColorAt (1.0000, Qt::red);

  QPainter painter (this);
  painter.setPen (Qt::NoPen);

  QBrush brush (gradient);

  painter.setBrush (brush);
  painter.drawRect (0,
                    0,
                    rect().width (),
                    rect().height ());
}
开发者ID:gitter-badger,项目名称:engauge6,代码行数:25,代码来源:ViewProfileScale.cpp

示例11: p

void Button::paintEvent(QPaintEvent *event)
{
    QWidget::paintEvent(event);
    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing, true);

    QRect roundedRect(event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height());

    QPainterPath path(QPoint(roundedRect.left(), roundedRect.top() + d->topLeftRadius));
    path.quadTo(roundedRect.left(), roundedRect.top(), roundedRect.left() + d->topLeftRadius, roundedRect.top());
    path.lineTo(roundedRect.right() - d->topRightRadius, roundedRect.top());
    path.quadTo(roundedRect.right(), roundedRect.top(), roundedRect.right(), roundedRect.top()
                + d->topRightRadius);
    path.lineTo(roundedRect.right(), roundedRect.bottom() - d->bottomRightRadius);
    path.quadTo(roundedRect.right(), roundedRect.bottom(), roundedRect.right() -
                d->bottomRightRadius, roundedRect.bottom());
    path.lineTo(roundedRect.left() + d->bottomLeftRadius, roundedRect.bottom());
    path.quadTo(roundedRect.left(), roundedRect.bottom(), roundedRect.left(), roundedRect.bottom()
                - d->bottomLeftRadius);
    path.closeSubpath();

    QLinearGradient gradient;
    if(!d->pressed)
    {
        gradient = d->gradient;
    }
    if(d->pressed || (d->checked && d->checkable))
    {
        gradient = d->pressedGradient;
    }
    if(!isEnabled())
    {
        gradient = QLinearGradient(QPoint(0, 0), QPoint(0, height()));
        gradient.setColorAt(0, QColor(230, 230, 230));
        gradient.setColorAt(1, QColor(200, 200, 200));
    }
    gradient.setStart(QPoint(0, 0));
    gradient.setFinalStop(QPoint(0, height()));
    p.fillPath(path, QBrush(gradient));

    p.setPen(QColor(d->borderColor));
    p.drawPath(path);
    p.setPen(QColor(d->textColor));

    if(d->icon.isNull())
    {
        if(d->checked && d->checkable && !d->checkedText.isEmpty())
            p.drawText(roundedRect, Qt::AlignCenter, d->checkedText);
        if(!d->checkable || !d->checked || d->checkedText.isEmpty())
            p.drawText(roundedRect, Qt::AlignCenter, d->text);
    }
    else
    {
        if(d->checked && d->checkable && !d->checkedIcon.isNull())
               d->checkedIcon.paint(&p, roundedRect, Qt::AlignCenter);
        if(!d->checkable || !d->checked || d->checkedIcon.isNull())
            d->icon.paint(&p, roundedRect.x()+4, roundedRect.y()+4, roundedRect.width()-8
                          , roundedRect.height()-8,  Qt::AlignCenter);
    }
}
开发者ID:feda12,项目名称:Mooztik,代码行数:60,代码来源:button.cpp

示例12: QColor

void DkTransferToolBar::loadSettings() {

    QSettings& settings = Settings::instance().getSettings();
    settings.beginGroup("Pseudo Color");

    int gSize = settings.beginReadArray("oldGradients");

    for (int idx = 0; idx < gSize; idx++) {
        settings.setArrayIndex(idx);

        QVector<QGradientStop> stops;
        int sSize = settings.beginReadArray("gradient");

        for (int sIdx = 0; sIdx < sSize; sIdx++) {
            settings.setArrayIndex(sIdx);

            QGradientStop s;
            s.first = settings.value("posRGBA", 0).toFloat();
            s.second = QColor::fromRgba(settings.value("colorRGBA", QColor().rgba()).toInt());
            qDebug() << "pos: " << s.first << " col: " << s.second;
            stops.append(s);
        }
        settings.endArray();

        QLinearGradient g;
        g.setStops(stops);
        oldGradients.append(g);
    }

    settings.endArray();
    settings.endGroup();
}
开发者ID:examyes,项目名称:nomacs,代码行数:32,代码来源:DkToolbars.cpp

示例13: painter

void QProg::paintBorder()
{
    //int m_sizeW= 90;
    //int m_sizeH= 470;
    QPainter painter(this);
    painter.setWindow(0, 0, m_sizeW, m_sizeH);
    painter.setRenderHint(QPainter::Antialiasing);
    
    int m_linGradY = 40;
    //QLinearGradient linGrad(5, 40, 15, 40);
    // QLinearGradient linGrad(36, 5, 5, 15);
    QLinearGradient linGrad (40, m_sizeH-7, 40, m_sizeH-18);
    //QLinearGradient linGrad(m_sizeH, 5, m_sizeH, 15);
    linGrad.setColorAt(0, Qt::white);
    linGrad.setColorAt(1, Qt::black);
    linGrad.setSpread(QGradient::PadSpread);
    painter.setBrush(linGrad);
    QRectF border(5, 5, m_sizeW-10, m_sizeH-10);
    //QRectF border(0, 0, m_sizeW-10, m_sizeH);
    painter.drawRoundRect(border, 20, 5);

    // value rect
    painter.setBrush(QColor(70, 70, 70));
    QRectF value(nValueRectX, nValueRectY, m_sizeW/1.3, m_sizeH/15);
    painter.drawRoundRect(value, 15);

}
开发者ID:MakSim345,项目名称:QT-Dev,代码行数:27,代码来源:qprog.cpp

示例14: PremierPoint

/**
 * Décrit le façon de dessiner l'élément sur la scène
 *
 * @brief   Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget)
 * @param   pPainter    le pinceau servant à dessiner sur la scène
 * @param   option      Option sur le dessin (pas utile dans notre cas)
 * @param   widget      Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas)
 * @see     Item
 */
void Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    this->GererSelection(pPainter) ;
    this->sTexte = this->pInstRepresentee->toString() ;

    //Définition du dégradé
    qreal           top             (this->rect.top()) ;
    QPointF         PremierPoint    (0, top) ;
    QPointF         SecondPoint     (0, -top) ;
    QLinearGradient grad            (PremierPoint, SecondPoint) ;
    QColor          PremiereCouleur (0x5E, 0xC1, 0xFF, 0xFF) ;
    QColor          SecondeCouleur  (0x22, 0xAA, 0xFF, 0xFF) ;
    grad.setColorAt(0, PremiereCouleur) ;
    grad.setColorAt(1, SecondeCouleur) ;

    //Définition du brush
    QBrush brush(grad) ;
    pPainter->setBrush(brush) ;

    //Dessin de l'item
    qreal   Rayon           (-top) ;
    QPointF Centre          (0, 0) ;
    QRectF  RectTexte       (top, top, -2*top, -2*top) ;

    pPainter->drawEllipse(Centre, Rayon, Rayon) ;

    pPainter->setPen(QPen());
    pPainter->drawText(RectTexte, sTexte, QTextOption(Qt::AlignCenter)) ;
}
开发者ID:lna44700,项目名称:openorganigram,代码行数:38,代码来源:Item_Tempo.cpp

示例15: sizeForPainterScale

void StylePainterMobile::drawProgress(const QRect& rect, double progress, bool leftToRight, bool animated, bool vertical) const
{
    const int horizontalBorder = (vertical ? rect.width() / 4 : 0);
    const int verticalBorder = (vertical ? 0 : rect.height() / 4);
    const QRect targetRect = rect.adjusted(horizontalBorder, verticalBorder, -horizontalBorder, -verticalBorder);

    QPixmap result;
    QSize imageSize = sizeForPainterScale(targetRect);
    if (vertical)
        qSwap(imageSize.rheight(), imageSize.rwidth());
    KeyIdentifier id;
    id.type = KeyIdentifier::Progress;
    id.width = imageSize.width();
    id.height = imageSize.height();
    id.trait1 = animated;
    id.trait2 = (!animated && !leftToRight);
    id.trait3 = progress * 100;
    if (!findCachedControl(id, &result)) {
        if (imageSize.isNull())
            return;
        result = QPixmap(imageSize);
        result.fill(Qt::transparent);
        QPainter painter(&result);
        painter.setRenderHint(QPainter::Antialiasing);
        QRect progressRect(QPoint(0, 0), imageSize);
        qreal radius = radiusFactor * progressRect.height();
        painter.setBrush(Qt::NoBrush);
        painter.setPen(borderPen());
        progressRect.adjust(1, 1, -1, -1);
        painter.drawRoundedRect(progressRect, radius, radius);
        progressRect.adjust(1, 1, -1, -1);
        if (animated) {
            const int right = progressRect.right();
            const int startPos = right * (1 - progressBarChunkPercentage) * 2 * fabs(progress - 0.5);
            progressRect.setWidth(progressBarChunkPercentage * right);
            progressRect.moveLeft(startPos);
        } else {
            progressRect.setWidth(progress * progressRect.width());
            if (!leftToRight)
                progressRect.moveRight(imageSize.width() - 2);
        }
        if (progressRect.width() > 0) {
            QLinearGradient gradient;
            gradient.setStart(progressRect.bottomLeft());
            gradient.setFinalStop(progressRect.topLeft());
            gradient.setColorAt(0.0, highlightColor);
            gradient.setColorAt(1.0, highlightColor.lighter());
            painter.setBrush(gradient);
            painter.setPen(Qt::NoPen);
            radius = radiusFactor * progressRect.height();
            painter.drawRoundedRect(progressRect, radius, radius);
        }
        insertIntoCache(id, result);
    }
    QTransform transform;
    transform.rotate(-90);
    painter->drawPixmap(targetRect, vertical ? result.transformed(transform) : result);
}
开发者ID:xiaolu31,项目名称:webkit-node,代码行数:58,代码来源:RenderThemeQtMobile.cpp


注:本文中的QLinearGradient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。