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


C++ QLinearGradient::setColorAt方法代码示例

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


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

示例1: QLinearGradient

void
InfoBar::resizeEvent( QResizeEvent* e )
{
    QWidget::resizeEvent( e );

    QLinearGradient gradient = QLinearGradient( contentsRect().topLeft(), contentsRect().bottomRight() );
    gradient.setColorAt( 0.0, QColor( 100, 100, 100 ) );
    gradient.setColorAt( 1.0, QColor( 63, 63, 63 ) );

    QPalette p = palette();
    p.setBrush( QPalette::Window, QBrush( gradient ) );
    setPalette( p );
}
开发者ID:hatstand,项目名称:tomahawk,代码行数:13,代码来源:infobar.cpp

示例2: linearG

QLinearGradient KCategoryDrawer::linearG ( const QStyleOption &option, const QColor col ) const 
{

    QLinearGradient gradient = QLinearGradient(option.rect.topLeft(),
                             			   option.rect.bottomRight());

    gradient.setColorAt(option.direction == Qt::LeftToRight ? 0
                                                            : 1, col);
    gradient.setColorAt(option.direction == Qt::LeftToRight ? 1
                                                            : 0, Qt::transparent);

    return gradient;
}
开发者ID:mvidner,项目名称:yast-control-center,代码行数:13,代码来源:kcategorydrawer.cpp

示例3: resizeEvent

void HudWindow::resizeEvent(QResizeEvent* event)
{
    Q_UNUSED(event);

    if (desktopCompositingEnabled)
    {
        // Pre-draw the window drop shadow.  It only needs to be drawn upon
        // resize.  We do this because applying a blur effect to the drop
        // shadow is computationally expensive.

        // First, draw the shadow, using a pleasant gradient.
        QLinearGradient shadowGradient;
        shadowGradient.setStart(rect().width() / 2, 0.0);
        shadowGradient.setFinalStop(rect().width() / 2, rect().height());
        shadowGradient.setColorAt(0.0, QColor(0, 0, 0, 20));
        shadowGradient.setColorAt(1.0, QColor(0, 0, 0, 200));

        QImage unblurredImage
            (
                rect().width(),
                rect().height(),
                QImage::Format_ARGB32_Premultiplied
            );
        unblurredImage.fill(Qt::transparent);

        QPainter painter(&unblurredImage);
        painter.setRenderHint(QPainter::Antialiasing);
        painter.setPen(QPen(Qt::NoPen));
        painter.setBrush(QBrush(shadowGradient));
        painter.drawRoundedRect(rect().adjusted(10, 10, -10, -8), 5, 5);
        painter.end();

        // Now we need to blur the shadow onto its final destination image,
        // dropShadowImg, which will be drawn on the next paintEvent().
        //
        dropShadowImg = QImage
            (
                rect().width(),
                rect().height(),
                QImage::Format_ARGB32_Premultiplied
            );
        dropShadowImg.fill(Qt::transparent);

        painter.begin(&dropShadowImg);
        painter.setRenderHint(QPainter::Antialiasing);

        // Note that the blur only applies to the alpha channel.
        qt_blurImage(&painter, unblurredImage, 20, true, true);
        painter.end();
    }
}
开发者ID:p2edwards,项目名称:ghostwriter,代码行数:51,代码来源:HudWindow.cpp

示例4: drawBackground

void QIItemDelegate::drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,
                                     const QModelIndex &aIndex) const
{
#if MAC_LEOPARD_STYLE
    NOREF (aIndex);
    /* Macify for Leopard */
    if (aOption.state & QStyle::State_Selected)
    {
        /* Standard color for selected items and focus on the widget */
        QColor topLineColor (69, 128, 200);
        QColor topGradColor (92, 147, 214);
        QColor bottomGradColor (21, 83, 169);
        /* Color for selected items and no focus on the widget */
        if (QWidget *p = qobject_cast<QWidget *> (parent()))
            if (!p->hasFocus())
            {
                topLineColor.setRgb (145, 160, 192);
                topGradColor.setRgb (162, 177, 207);
                bottomGradColor.setRgb (110, 129, 169);
            }
        /* Color for selected items and no focus on the application at all */
        if (qApp->focusWidget() == NULL)
            {
                topLineColor.setRgb (151, 151, 151);
                topGradColor.setRgb (180, 180, 180);
                bottomGradColor.setRgb (137, 137, 137);
            }
        /* Paint the background */
        QRect r = aOption.rect;
        r.setTop (r.top() + 1);
        QLinearGradient linearGrad (QPointF(0, r.top()), QPointF(0, r.bottom()));
        linearGrad.setColorAt (0, topGradColor);
        linearGrad.setColorAt (1, bottomGradColor);
        aPainter->setPen (topLineColor);
        aPainter->drawLine (r.left(), r.top() - 1, r.right(), r.top() - 1);
        aPainter->fillRect (r, linearGrad);
    }
    else
    {
        /* Color for items and no focus on the application at all */
        QColor bgColor (212, 221, 229);
        if (qApp->focusWidget() == NULL)
            bgColor.setRgb (232, 232, 232);
        aPainter->fillRect(aOption.rect, bgColor);
    }
#else /* MAC_LEOPARD_STYLE */
    QItemDelegate::drawBackground (aPainter, aOption, aIndex);
#endif /* MAC_LEOPARD_STYLE */
}
开发者ID:Klanly,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:49,代码来源:QIListView.cpp

示例5: paint

//! [3]
void Enemy::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    //if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || painter->paintEngine()->type() == QPaintEngine::OpenGL){
    //    //qDebug()<<"OpenGL reporting!";
    //}
    // QPainter: (uses OpenGL for rectangles, ellipses etc. if above if-clause is true..?)
    // Body
    //painter->setBrush(myColour);
    static QLinearGradient hullGradient(0,-25,0,5);
    hullGradient.setColorAt(0, Qt::white);
    hullGradient.setColorAt(1, myColour);
    painter->setBrush(QBrush(hullGradient));
    // painter->drawEllipse(-10, -20, 20, 40);
    static const QPointF hullPoints[3] = {
        QPointF(-5.0, 10),
        QPointF(0, -30),
        QPointF(5, 10)
    };
    painter->drawPolygon(hullPoints, 3);

    // "Scanner" eye
    painter->setBrush(Qt::red);
    painter->drawEllipse(-4, -20, 8, 8);

    // Guns
    painter->setBrush(Qt::gray);
    painter->drawRect(-16,-12,4,8);
    painter->drawRect(12,-12,4,8);
    //  Pupil of "Scanner"
    qreal dx = ::sin(Creature::myAngle) * 10;
    myEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
    painter->drawEllipse(QRectF(-2.0 + 2*myEyeDirection, -22, 4, 4));

    // Wings
    //painter->setBrush(myIsCaught ? Qt::red : Qt::darkYellow);
    static QConicalGradient wingGradient(0,12,180);
    wingGradient.setColorAt(0, Qt::white);
    wingGradient.setColorAt(1, Creature::myIsCaught ? Qt::red : Qt::darkYellow); //Qt::gray);
    painter->setBrush(QBrush(wingGradient));
    //1st way of implementing the wings
    static const QPointF wingPoints[4] = {
        QPointF(0, 12),
        QPointF(-25, -14),
        QPointF(0, 4),
        QPointF(25, -14)
    };
    painter->drawPolygon(wingPoints, 4);
}
开发者ID:mjafin,项目名称:TrapSKEM,代码行数:49,代码来源:enemy.cpp

示例6: paintEvent

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

示例7: paintBorder

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

示例8: 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

示例9: drawPalette

void KColorValueSelector::drawPalette( QPixmap *pixmap )
{
    QColor color;
    if (chooserMode() == ChooserHue) {
        color.setHsv(hue(), 255, 255);
    } else {
        color.setHsv(hue(), saturation(), colorValue());
    }

    QLinearGradient gradient;
    if (orientation() == Qt::Vertical) {
        gradient.setStart(0, contentsRect().height());
        gradient.setFinalStop(0, 0);
    } else {
        gradient.setStart(0, 0);
        gradient.setFinalStop(contentsRect().width(), 0);
    }

    const int steps = componentValueSteps(chooserMode());
    for (int v = 0; v <= steps; ++v) {
        setComponentValue(color, chooserMode(), v * (1.0 / steps));
        gradient.setColorAt(v * (1.0 / steps), color);
    }

    *pixmap = QPixmap(contentsRect().size());
    QPainter painter(pixmap);
    painter.fillRect(pixmap->rect(), gradient);
}
开发者ID:vasi,项目名称:kdelibs,代码行数:28,代码来源:kcolorvalueselector.cpp

示例10: paintActiveOverlay

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

示例11: drawCheckableBackground

void StylePainterMobile::drawCheckableBackground(QPainter* painter, const QRect& rect, bool checked, bool enabled) const
{
    QBrush brush;
    QColor color = Qt::gray;
    if (checked && enabled)
        color = highlightColor;

    QLinearGradient gradient;
    gradient.setStart(rect.topLeft());
    gradient.setFinalStop(rect.bottomLeft());
    gradient.setColorAt(0.0, color);
    gradient.setColorAt(1.0, color.lighter(130));
    brush = gradient;

    drawControlBackground(painter, borderPen(painter), rect, brush);
}
开发者ID:xiaolu31,项目名称:webkit-node,代码行数:16,代码来源:RenderThemeQtMobile.cpp

示例12: benchmarkGradient

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

示例13: drawLabel

//---------------------------------------------------------------
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

示例14: 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

示例15: drawSelectionBackground

static void drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
    painter->save();
    QLinearGradient gradient;
    QColor highlight = option.palette.highlight().color();
    gradient.setColorAt(0, highlight.lighter(130));
    gradient.setColorAt(1, highlight.darker(130));
    gradient.setStart(option.rect.topLeft());
    gradient.setFinalStop(option.rect.bottomLeft());
    painter->fillRect(option.rect, gradient);
    painter->setPen(highlight.lighter());
    painter->drawLine(option.rect.topLeft(),option.rect.topRight());
    painter->setPen(highlight.darker());
    painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
    painter->restore();
}
开发者ID:Jorsorokin,项目名称:julia-studio,代码行数:16,代码来源:itemlibrarycomponents.cpp


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