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


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

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


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

示例1: createRectGradient

QImage createRectGradient(int width, int height, const QGradient &gradient)
{
    QImage::Format format = QImage::Format_ARGB32_Premultiplied;
    QImage buffer(width, height, format);
    buffer.fill( qRgba(255, 255,255, 255) );

    QPainter painter(&buffer);
    painter.setPen(Qt::NoPen);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setCompositionMode(QPainter::CompositionMode_DestinationAtop);

    // Divide the rectangle into four triangles, each facing North, South,
    // East, and West. Every triangle will have its bounding box and linear
    // gradient.
    QLinearGradient linearGradient;

    // from center going North
    linearGradient = QLinearGradient(0, 0, width, height / 2);
    linearGradient.setStops( gradient.stops() );
    linearGradient.setStart(width / 2, height / 2);
    linearGradient.setFinalStop(width / 2, 0);
    painter.setBrush(linearGradient);
    painter.drawRect(0, 0, width, height / 2);

    // from center going South
    linearGradient = QLinearGradient(0, 0, width, height / 2);
    linearGradient.setStops( gradient.stops() );
    linearGradient.setStart(width / 2, height / 2);
    linearGradient.setFinalStop(width / 2, height);
    painter.setBrush(linearGradient);
    painter.drawRect(0, height / 2, width, height / 2);

    // clip the East and West portion
    QPainterPath clip;
    clip.moveTo(width, 0);
    clip.lineTo(width, height);
    clip.lineTo(0, 0);
    clip.lineTo(0, height);
    clip.closeSubpath();
    painter.setClipPath(clip);

    // from center going East
    linearGradient = QLinearGradient(0, 0, width / 2, height);
    linearGradient.setStops( gradient.stops() );
    linearGradient.setStart(width / 2, height / 2);
    linearGradient.setFinalStop(width, height / 2);
    painter.setBrush(linearGradient);
    painter.drawRect(width / 2, 0, width, height);

    // from center going West
    linearGradient = QLinearGradient(0, 0, width / 2, height);
    linearGradient.setStops( gradient.stops() );
    linearGradient.setStart(width / 2, height / 2);
    linearGradient.setFinalStop(0, height / 2);
    painter.setBrush(linearGradient);
    painter.drawRect(0, 0, width / 2, height);

    painter.end();
    return buffer;
}
开发者ID:shinsterneck,项目名称:hotshots,代码行数:60,代码来源:PostEffect.cpp

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

示例3: QColor

QWidget *DataPlot::createAccPlot()
{
    // setup plot
    m_accPlot->yAxis->setRange(-256,256);
    m_accPlot->xAxis->setTickLength(1);

    // set some pens, brushes and backgrounds:
    m_accPlot->xAxis->setBasePen(QPen(Qt::white, 1));
    m_accPlot->yAxis->setBasePen(QPen(Qt::white, 1));
    m_accPlot->xAxis->setTickPen(QPen(Qt::white, 1));
    m_accPlot->yAxis->setTickPen(QPen(Qt::white, 1));
    m_accPlot->xAxis->setSubTickPen(QPen(Qt::white, 1));
    m_accPlot->yAxis->setSubTickPen(QPen(Qt::white, 1));
    m_accPlot->xAxis->setTickLabelColor(Qt::white);
    m_accPlot->yAxis->setTickLabelColor(Qt::white);
    m_accPlot->xAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
    m_accPlot->yAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
    m_accPlot->xAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
    m_accPlot->yAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
    m_accPlot->xAxis->grid()->setSubGridVisible(true);
    m_accPlot->yAxis->grid()->setSubGridVisible(true);
    m_accPlot->xAxis->grid()->setZeroLinePen(Qt::NoPen);
    m_accPlot->yAxis->grid()->setZeroLinePen(Qt::NoPen);
    m_accPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    m_accPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    QLinearGradient plotGradient;
    plotGradient.setStart(0, 0);
    plotGradient.setFinalStop(0, 350);
    plotGradient.setColorAt(0, QColor(80, 80, 80));
    plotGradient.setColorAt(1, QColor(50, 50, 50));
    m_accPlot->setBackground(plotGradient);
    QLinearGradient axisRectGradient;
    axisRectGradient.setStart(0, 0);
    axisRectGradient.setFinalStop(0, 350);
    axisRectGradient.setColorAt(0, QColor(80, 80, 80));
    axisRectGradient.setColorAt(1, QColor(30, 30, 30));
    m_accPlot->axisRect()->setBackground(axisRectGradient);

    // create graphs

    // Acc x graph
    m_accPlot->addGraph();
    m_accPlot->graph(0)->setData(m_acc_x_Values,m_timestamps);
    m_accPlot->graph(0)->setPen(QPen(Qt::blue));

    // Acc y graph
    m_accPlot->addGraph();
    m_accPlot->graph(1)->setData(m_acc_y_Values,m_timestamps);
    m_accPlot->graph(1)->setPen(QPen(Qt::red));

    // Acc z graph
    m_accPlot->addGraph();
    m_accPlot->graph(2)->setData(m_acc_z_Values,m_timestamps);
    m_accPlot->graph(2)->setPen(QPen(Qt::green));

    m_accPlot->replot();
    return m_accPlot;
}
开发者ID:t-mon,项目名称:imu-viewer,代码行数:58,代码来源:dataplot.cpp

示例4: setupRealtimeDataDemo

void Form::setupRealtimeDataDemo(QCustomPlot *customPlot)
{
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
  QMessageBox::critical(this, "", "You're using Qt < 4.7, the realtime data demo needs functions that are available with Qt 4.7 to work properly");
#endif
  demoName = "Real Time Data Demo";

  customPlot->addGraph(); // blue line
  customPlot->graph(0)->setPen(QPen(Qt::blue));
  customPlot->graph(0)->setBrush(QBrush(QColor(96, 227, 69)));
  customPlot->graph(0)->setAntialiasedFill(true);

  customPlot->addGraph(); // red line
  customPlot->graph(1)->setPen(QPen(Qt::red));
  customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));

  customPlot->addGraph(); // blue dot
  customPlot->graph(2)->setPen(QPen(Qt::blue));
  customPlot->graph(2)->setLineStyle(QCPGraph::lsNone);
  customPlot->graph(2)->setScatterStyle(QCPScatterStyle::ssDisc);

  customPlot->addGraph(); // red dot
  customPlot->graph(3)->setPen(QPen(Qt::red));
  customPlot->graph(3)->setLineStyle(QCPGraph::lsNone);
  customPlot->graph(3)->setScatterStyle(QCPScatterStyle::ssDisc);

  customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
  customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
  customPlot->xAxis->setAutoTickStep(false);
  customPlot->xAxis->setTickStep(2);
  customPlot->axisRect()->setupFullAxesBox();

  QLinearGradient plotGradient;
  plotGradient.setStart(0, 0);
  plotGradient.setFinalStop(0, 300);
  plotGradient.setColorAt(0, QColor(80, 8, 80));
  plotGradient.setColorAt(1, QColor(0, 0, 0));
  customPlot->setBackground(plotGradient);

  QLinearGradient axisRectGradient;
  axisRectGradient.setStart(0, 0);
  axisRectGradient.setFinalStop(0, 350);
  axisRectGradient.setColorAt(0, QColor(80, 80, 80));
  axisRectGradient.setColorAt(1, QColor(30, 100, 0));
  customPlot->axisRect()->setBackground(axisRectGradient);

  //QPoint pt1(10, 20);

  // setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
 connect(&dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));
  dataTimer.start(1); // Interval 0 means to refresh as fast as possible
}
开发者ID:Rdm1,项目名称:Prob2,代码行数:52,代码来源:interfaceform.cpp

示例5: paintBackground

/* static */
void UIGSelectorItem::paintBackground(QPainter *pPainter, const QRect &rect,
                                      bool fHasParent, bool fIsSelected,
                                      int iGradientDarkness, DragToken dragTokenWhere)
{
    /* Fill rectangle with brush: */
    QPalette pal = QApplication::palette();
    QColor base = pal.color(QPalette::Active, fIsSelected ? QPalette::Highlight : QPalette::Window);
    pPainter->fillRect(rect, pal.brush(QPalette::Active, QPalette::Base));

    /* Add gradient: */
    QLinearGradient lg(rect.topLeft(), rect.topRight());
    /* For non-root item: */
    if (fHasParent)
    {
        /* Background is animated if drag token missed: */
        lg.setColorAt(0, base.darker(dragTokenWhere == DragToken_Off ? iGradientDarkness : 115));
        lg.setColorAt(1, base.darker(105));
    }
    else
    {
        /* Background is simple: */
        lg.setColorAt(0, base.darker(100));
        lg.setColorAt(1, base.darker(100));
    }
    pPainter->fillRect(rect, lg);

    /* Paint drag token UP? */
    if (dragTokenWhere != DragToken_Off)
    {
        QLinearGradient dragTokenGradient;
        QRect dragTokenRect = rect;
        if (dragTokenWhere == DragToken_Up)
        {
            dragTokenRect.setHeight(10);
            dragTokenGradient.setStart(dragTokenRect.bottomLeft());
            dragTokenGradient.setFinalStop(dragTokenRect.topLeft());
        }
        else if (dragTokenWhere == DragToken_Down)
        {
            dragTokenRect.setTopLeft(dragTokenRect.bottomLeft() - QPoint(0, 10));
            dragTokenGradient.setStart(dragTokenRect.topLeft());
            dragTokenGradient.setFinalStop(dragTokenRect.bottomLeft());
        }
        dragTokenGradient.setColorAt(0, base.darker(115));
        dragTokenGradient.setColorAt(1, base.darker(150));
        pPainter->fillRect(dragTokenRect, dragTokenGradient);
    }
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:49,代码来源:UIGSelectorItem.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: 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

示例8: _drawLines

        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

示例9: drawProgress

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

示例10: gradient

QGradient GradientDialog::gradient() const
{
    QLinearGradient gradient;
    gradient.setStart( 0, 0 );
    gradient.setStart( 1, 0 );
    gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
    Q_FOREACH( const QGradientStop &stop, d->m_gradient )
        gradient.setColorAt( stop.first, stop.second );
    return gradient;
}
开发者ID:KDE,项目名称:kdiagram,代码行数:10,代码来源:gradientdialog.cpp

示例11: paintEvent

void KarbonGradientWidget::paintEvent(QPaintEvent*)
{
    int w = width() - 4;  // available width for gradient and points
    int h = height() - 7; // available height for gradient and points
    int ph = colorStopBorder_height + 2; // point marker height
    int gh = h - ph;       // gradient area height

    QPainter painter(this);

    QLinearGradient gradient;
    gradient.setStart(QPointF(2, 2));
    gradient.setFinalStop(QPointF(width() - 2, 2));
    gradient.setStops(m_stops);

    m_checkerPainter.paint(painter, QRectF(2, 2, w, gh));

    painter.setBrush(QBrush(gradient));
    painter.drawRect(QRectF(2, 2, w, gh));

    painter.setBrush(QBrush());
    painter.setPen(palette().light().color());

    // light frame around widget
    QRect frame(1, 1, width() - 2, height() - 2);
    painter.drawRect(frame);

    // light line between gradient and point area
    painter.drawLine(QLine(QPoint(1, 3 + gh), QPoint(width() - 1, 3 + gh)));

    painter.setPen(palette().dark().color());
    // left-top frame around widget
    painter.drawLine(QPoint(), QPoint(0, height() - 1));
    painter.drawLine(QPoint(), QPoint(width() - 1, 0));

    // right-bottom from around gradient
    painter.drawLine(QPoint(width() - 2, 2), QPoint(width() - 2, 2 + gh));
    painter.drawLine(QPoint(width() - 2, 2 + gh), QPoint(2, 2 + gh));

    // upper line around point area
    painter.drawLine(QPoint(1, height() - 3 - ph), QPoint(width() - 1, height() - 3 - ph));

    // right-bottom line around point area
    painter.drawLine(QPoint(width() - 2, height() - ph - 1), QPoint(width() - 2, height() - 2));
    painter.drawLine(QPoint(width() - 2, height() - 2), QPoint(2, height() - 2));

    m_pntArea.setRect(2, height() - ph - 2, w, ph);
    painter.fillRect(m_pntArea.x(), m_pntArea.y(), m_pntArea.width(), m_pntArea.height(), palette().window().color());

    painter.setClipRect(m_pntArea.x(), m_pntArea.y(), m_pntArea.width(), m_pntArea.height());
    painter.translate(m_pntArea.x(), m_pntArea.y());

    foreach(const QGradientStop & stop, m_stops)
    paintColorStop(painter, (int)(stop.first * m_pntArea.width()), stop.second);
}
开发者ID:foren197316,项目名称:calligra,代码行数:54,代码来源:KarbonGradientWidget.cpp

示例12:

void GradientDialog::Private::updateGradientDisplay()
{
    QLinearGradient gradient;
    gradient.setStart( 0, 0 );
    gradient.setStart( 1, 0 );
    gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
    Q_FOREACH( const QGradientStop &stop, m_gradient )
        gradient.setColorAt( stop.first, stop.second );
    QPalette palette = ui->gradientDisplay->palette();
    palette.setBrush( QPalette::Background, gradient );
    ui->gradientDisplay->setPalette( palette );
}
开发者ID:KDE,项目名称:kdiagram,代码行数:12,代码来源:gradientdialog.cpp

示例13: resizeEvent

void ViSpectrumWidget::resizeEvent(QResizeEvent *event)
{
	mMainHeight = height() * MIRROR_RATIO;

	QLinearGradient mainGradient;
	QLinearGradient mirrorGradient;

	mainGradient.setStart(0, mMainHeight);
	mainGradient.setFinalStop(0, 0);
	mainGradient.setColorAt(0, ViThemeManager::color(ViThemeColors::MainColor6));
	mainGradient.setColorAt(1, ViThemeManager::color(ViThemeColors::MainColor1));

	mirrorGradient.setStart(0, height() - mMainHeight);
	mirrorGradient.setFinalStop(0, height());
	mirrorGradient.setColorAt(0, ViThemeManager::color(ViThemeColors::MainColor6));
	mirrorGradient.setColorAt(0.5, ViThemeManager::color(ViThemeColors::MainColor6));
	mirrorGradient.setColorAt(1, Qt::transparent);

	mMainBrush = QBrush(mainGradient);
	mMirrorBrush = QBrush(mirrorGradient);
}
开发者ID:EQ4,项目名称:Visore,代码行数:21,代码来源:vispectrumwidget.cpp

示例14: paint

void KoResourceItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
    if( ! index.isValid() )
        return;

    KoResource * resource = static_cast<KoResource*>( index.internalPointer() );
    if (!resource)
        return;

    painter->save();

    if (option.state & QStyle::State_Selected)
        painter->fillRect( option.rect, option.palette.highlight() );

    QRect innerRect = option.rect.adjusted( 2, 1, -2, -1 );

    KoAbstractGradient * gradient = dynamic_cast<KoAbstractGradient*>( resource );
    if (gradient) {
        QGradient * g = gradient->toQGradient();

        QLinearGradient paintGradient;
        paintGradient.setStops( g->stops() );
        paintGradient.setStart( innerRect.topLeft() );
        paintGradient.setFinalStop( innerRect.topRight() );

        m_checkerPainter.paint( *painter, innerRect );
        painter->fillRect( innerRect, QBrush( paintGradient ) );

        delete g;
    }
    else {
        QImage thumbnail = index.data( Qt::DecorationRole ).value<QImage>();

        QSize imageSize = thumbnail.size();

        if(imageSize.height() > innerRect.height() || imageSize.width() > innerRect.width()) {
            qreal scaleW = static_cast<qreal>( innerRect.width() ) / static_cast<qreal>( imageSize.width() );
            qreal scaleH = static_cast<qreal>( innerRect.height() ) / static_cast<qreal>( imageSize.height() );

            qreal scale = qMin( scaleW, scaleH );

            int thumbW = static_cast<int>( imageSize.width() * scale );
            int thumbH = static_cast<int>( imageSize.height() * scale );
            thumbnail = thumbnail.scaled( thumbW, thumbH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
        }
        painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
        if (thumbnail.hasAlphaChannel()) {
            painter->fillRect(innerRect, Qt::white); // no checkers, they are confusing with patterns.
        }
        painter->fillRect( innerRect, QBrush(thumbnail) );
    }
    painter->restore();
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:53,代码来源:KoResourceItemDelegate.cpp

示例15: findPushButton

QPixmap StylePainterMobile::findPushButton(const QSize& size, bool sunken, bool enabled) const
{
    QPixmap result;
    KeyIdentifier id;
    id.type = KeyIdentifier::PushButton;
    id.width = size.width();
    id.height = size.height();
    id.trait1 = sunken;
    id.trait2 = enabled;
    if (!findCachedControl(id, &result)) {
        const qreal dropShadowSize = painterScale(painter);
        result = QPixmap(size);
        result.fill(Qt::transparent);
        const QRect rect = QRect(0, 0, size.width(), size.height() - dropShadowSize);
        QPainter cachePainter(&result);
        drawControlBackground(&cachePainter, Qt::NoPen, rect.adjusted(0, dropShadowSize, 0, dropShadowSize), shadowColor);

        QBrush brush;
        if (enabled && !sunken) {
            QLinearGradient linearGradient;
            linearGradient.setStart(rect.bottomLeft());
            linearGradient.setFinalStop(rect.topLeft());
            linearGradient.setColorAt(0.0, buttonGradientBottom);
            linearGradient.setColorAt(1.0, Qt::white);
            brush = linearGradient;
        } else if (!enabled)
            brush = QColor(241, 242, 243);
        else { // sunken
            QLinearGradient linearGradient;
            linearGradient.setStart(rect.bottomLeft());
            linearGradient.setFinalStop(rect.topLeft());
            linearGradient.setColorAt(0.0, highlightColor);
            linearGradient.setColorAt(1.0, highlightColor.lighter());
            brush = linearGradient;
        }
        drawControlBackground(&cachePainter, borderPen(painter), rect, brush);
        insertIntoCache(id, result);
    }
    return result;
}
开发者ID:xiaolu31,项目名称:webkit-node,代码行数:40,代码来源:RenderThemeQtMobile.cpp


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