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


C++ QRadialGradient类代码示例

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


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

示例1: QDialog

WaitingDialog::WaitingDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::WaitingDialog)
{
    ui->setupUi(this);

    m_rot = 0;

    QGraphicsScene* scene = new QGraphicsScene();
    ui->graphicsView->setScene(scene);

    QRect rect(0,0,50,50);

    m_startPoint = QPoint(0,ui->graphicsView->rect().size().height()/2);
    m_endPoint = QPoint(ui->graphicsView->rect().size().width(),ui->graphicsView->rect().size().height()/2);

    QRadialGradient rg = QRadialGradient(10,10,45.0);

    QColor mcol(Qt::blue);
    mcol.setAlpha(255);
    rg.setColorAt(0.0,Qt::white);
    mcol.setBlue(mcol.blue()-15);
    rg.setColorAt(0.5,mcol);
    mcol.setBlue(mcol.blue()+15);
    rg.setColorAt(1.0,mcol);

    QPen pen(mcol);
    QPixmap pm(rect.size()+QSize(1,1));
    pm.fill(Qt::transparent);

    QPainter p(&pm);
    p.setBackgroundMode(Qt::TransparentMode);
    p.setBrush(rg);
    p.setPen(pen);
    p.drawEllipse(rect);

    m_ellipse = new MyItem(pm);
    m_ellipse->setPos(m_startPoint);
    ui->graphicsView->scene()->addItem(m_ellipse);

    m_anim = new QPropertyAnimation(m_ellipse,"pos");
    connect(m_anim,SIGNAL(finished()),this,SLOT(animFinished()));
    m_anim->setEasingCurve(QEasingCurve::OutBounce);
    m_anim->setStartValue(m_startPoint);
    m_anim->setEndValue(m_endPoint);
    m_anim->setDuration(2000);
    m_anim->setLoopCount(1);
    m_anim->start();

    m_timer = new QTimer(this);
    connect(m_timer,SIGNAL(timeout()),this,SLOT(timeout()));
    m_timer->setInterval(100);

#if defined(Q_OS_SYMBIAN)
    this->showMaximized();
#else
    this->show();
#endif
    m_timer->start();
}
开发者ID:juhanapaavola,项目名称:swiiplayer,代码行数:60,代码来源:waitingdialog.cpp

示例2: qMin

void DashBar::repaint(QPainter &painter){
    float v;
    float min = qMin(value1,value2);
    float max = qMax(value1,value2);
    int size = orientation == Qt::Horizontal? width-10 : height-10;

    QRadialGradient gradient;
    QPen pen(Qt::black);
    pen.setWidth(1);

    painter.save();
    painter.setRenderHint(QPainter::Antialiasing);
    painter.translate(x,y);

    gradient = QRadialGradient(QPointF(0,0), qSqrt(width*width+height*height)*2, QPointF(0,0));
    gradient.setColorAt(0, QColor(224,224,224));
    gradient.setColorAt(1, QColor(28,28,28));
    painter.setPen(pen);
    painter.setBrush(QBrush(gradient));
    painter.drawRect(0,0,width, height);

    gradient = QRadialGradient(QPointF(width,height), qSqrt(width*width+height*height)*2, QPointF(width,height));
    gradient.setColorAt(0, QColor(88,88,88));
    gradient.setColorAt(1, QColor(28,28,28));
    painter.setPen(pen);
    painter.setBrush(QBrush(gradient));
    painter.drawRect(5,5,width-10,height-10);

    painter.setBrush(Qt::white);
    painter.setPen(Qt::white);

    if(value>max)value = max;
    if(value<min)value = min;
    v = (max-value)/(max-min)*size;

    for(int i=0; i<size; i+=4){
        if(i>size*0.4f){
            painter.setPen(i>=v || isSelected? Qt::green : QColor(Qt::green).darker());
        }else if(i>=size*0.1f && i<=size*0.4f){
            painter.setPen(i>=v || isSelected? Qt::yellow : QColor(Qt::yellow).darker());
        }else{
            painter.setPen(i>=v || isSelected? Qt::red : QColor(Qt::red).darker());
        }

        if(orientation == Qt::Horizontal){ //Orizzontale
            painter.drawLine(width-6-i,6,width-6-i,height-6); //Linee verticali
        }else{
            painter.drawLine(6,6+i,width-6,6+i);
        }

    }

    painter.restore();
}
开发者ID:DavideMalvezzi,项目名称:EscorpioEvo15-DAQSystem,代码行数:54,代码来源:dashbar.cpp

示例3: painter

void BrushEngine::paint(const QPointF& point, float pressure) {
    QPainter painter(eraser > 50 ? canvasItem->getPixmap() : canvasBuffer->getPixmap());
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setPen(Qt::NoPen);
    if (eraser > 50) {
        painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
    }

    color.setAlpha(qRound(255 * flow / 100.0));
    QColor pressureColor = color;
    pressureColor.setAlpha(qRound(color.alpha() * pressure));
    QColor alphaColor = color;
    alphaColor.setAlpha(0);

    QRadialGradient radialGradient;
    radialGradient.setRadius(size / 2.0);
    radialGradient.setColorAt(0, pressureColor);
    radialGradient.setColorAt(1, alphaColor);
    radialGradient.setColorAt(hardness / 100.0, pressureColor);
    painter.setBrush(QBrush(radialGradient));

    if (startPoint.isNull()) {
        startPoint = QPointF(point);
        lastPoint = QPointF(point);
        topleft = QPoint(0, 0);
        bottomright = QPoint(canvasBuffer->getPixmap()->width(), canvasBuffer->getPixmap()->height());
        paintDab(point, painter);
    } else {
        qreal length = qSqrt(qPow(lastPoint.x() - point.x(), 2) + qPow(lastPoint.y() - point.y(), 2));
        qreal delta = size * spacing / 2.0 / 100.0;

        if (length >= delta) {
            int dabs = qRound(length / delta);
            qreal angle = qAtan2(point.x() - lastPoint.x(), point.y() - lastPoint.y());
            qreal deltaX = delta * qSin(angle);
            qreal deltaY = delta * qCos(angle);

            QPointF betweenPoint;
            for (int i = 1; i <= dabs; i++) {
                qreal x = lastPoint.x() + deltaX * i +
                        (10000 - qrand() % 20000) / 10000.0 * size * jitter / 100;
                qreal y = lastPoint.y() + deltaY * i +
                        (10000 - qrand() % 20000) / 10000.0 * size * jitter / 100;
                betweenPoint = QPointF(x, y);
                paintDab(betweenPoint, painter);

            }
            lastPoint = betweenPoint;
        }
    }
}
开发者ID:krre,项目名称:aprilbrush,代码行数:51,代码来源:BrushEngine.cpp

示例4: EllipseShape

KoShape *EllipseShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
{
    EllipseShape *ellipse = new EllipseShape();

    ellipse->setStroke(new KoShapeStroke(1.0));
    ellipse->setShapeId(KoPathShapeId);

    QRadialGradient *gradient = new QRadialGradient(QPointF(0.5,0.5), 0.5, QPointF(0.25,0.25));
    gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient->setColorAt(0.0, Qt::white);
    gradient->setColorAt(1.0, Qt::green);
    ellipse->setBackground(new KoGradientBackground(gradient));

    return ellipse;
}
开发者ID:NavyZhao1978,项目名称:QCalligra,代码行数:15,代码来源:EllipseShapeFactory.cpp

示例5: KoStopGradient

KoStopGradient * KoStopGradient::fromQGradient(QGradient * gradient)
{
    if (! gradient)
        return 0;

    KoStopGradient * newGradient = new KoStopGradient("");
    newGradient->setType(gradient->type());
    newGradient->setSpread(gradient->spread());

    switch (gradient->type()) {
    case QGradient::LinearGradient: {
        QLinearGradient * g = static_cast<QLinearGradient*>(gradient);
        newGradient->m_start = g->start();
        newGradient->m_stop = g->finalStop();
        newGradient->m_focalPoint = g->start();
        break;
    }
    case QGradient::RadialGradient: {
        QRadialGradient * g = static_cast<QRadialGradient*>(gradient);
        newGradient->m_start = g->center();
        newGradient->m_stop = g->center() + QPointF(g->radius(), 0);
        newGradient->m_focalPoint = g->focalPoint();
        break;
    }
    case QGradient::ConicalGradient: {
        QConicalGradient * g = static_cast<QConicalGradient*>(gradient);
        qreal radian = g->angle() * M_PI / 180.0;
        newGradient->m_start = g->center();
        newGradient->m_stop = QPointF(100.0 * cos(radian), 100.0 * sin(radian));
        newGradient->m_focalPoint = g->center();
        break;
    }
    default:
        delete newGradient;
        return 0;
    }

    Q_FOREACH (const QGradientStop & stop, gradient->stops()) {
        KoColor color(newGradient->colorSpace());
        color.fromQColor(stop.second);
        newGradient->m_stops.append(KoGradientStop(stop.first, color));
    }

    return newGradient;
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:45,代码来源:KoStopGradient.cpp

示例6: getRect

void EditorMagnifierItem::updateMask()
{
    QRectF current = getRect();
    QSize box = QSize( current.width(), current.width() );

    // reupdate our mask
    if (m_imgMask.size() != box)
    {
        int radius = box.width() / 2;
        int ring = radius - 10;

        m_imgMask = QPixmap(box);
        m_imgMask.fill(Qt::transparent);

        QRadialGradient g;
        g.setCenter(radius, radius);
        g.setFocalPoint(radius, radius);
        g.setRadius(radius);
        g.setColorAt( 1.0, QColor(255, 255, 255, 0) );
        g.setColorAt( 0.5, QColor(128, 128, 128, 255) );

        QPainter mask(&m_imgMask);
        mask.setRenderHint(QPainter::Antialiasing);
        mask.setCompositionMode(QPainter::CompositionMode_Source);
        mask.setBrush(g);
        mask.setPen(Qt::NoPen);
        mask.drawRect( m_imgMask.rect() );
        mask.setBrush( QColor(Qt::transparent) );
        mask.drawEllipse(g.center(), ring, ring);
        mask.end();
    }
}
开发者ID:shinsterneck,项目名称:hotshots,代码行数:32,代码来源:EditorMagnifierItem.cpp

示例7: sipConvertFromNewType

static PyObject *meth_QRadialGradient_center(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QRadialGradient *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QRadialGradient, &sipCpp))
        {
            QPointF *sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = new QPointF(sipCpp->center());
            Py_END_ALLOW_THREADS

            return sipConvertFromNewType(sipRes,sipType_QPointF,NULL);
        }
    }
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:18,代码来源:sipQtGuiQRadialGradient.cpp

示例8: loadGradient

static QGradient loadGradient(const QDomElement &elem)
{
    if (elem.tagName() != QLatin1String("gradientData"))
        return QLinearGradient();

    const QGradient::Type type = stringToGradientType(elem.attribute(QLatin1String("type")));
    const QGradient::Spread spread = stringToGradientSpread(elem.attribute(QLatin1String("spread")));
    const QGradient::CoordinateMode mode = stringToGradientCoordinateMode(elem.attribute(QLatin1String("coordinateMode")));

    QGradient gradient = QLinearGradient();

    if (type == QGradient::LinearGradient) {
        QLinearGradient g;
        g.setStart(elem.attribute(QLatin1String("startX")).toDouble(), elem.attribute(QLatin1String("startY")).toDouble());
        g.setFinalStop(elem.attribute(QLatin1String("endX")).toDouble(), elem.attribute(QLatin1String("endY")).toDouble());
        gradient = g;
    } else if (type == QGradient::RadialGradient) {
        QRadialGradient g;
        g.setCenter(elem.attribute(QLatin1String("centerX")).toDouble(), elem.attribute(QLatin1String("centerY")).toDouble());
        g.setFocalPoint(elem.attribute(QLatin1String("focalX")).toDouble(), elem.attribute(QLatin1String("focalY")).toDouble());
        g.setRadius(elem.attribute(QLatin1String("radius")).toDouble());
        gradient = g;
    } else if (type == QGradient::ConicalGradient) {
        QConicalGradient g;
        g.setCenter(elem.attribute(QLatin1String("centerX")).toDouble(), elem.attribute(QLatin1String("centerY")).toDouble());
        g.setAngle(elem.attribute(QLatin1String("angle")).toDouble());
        gradient = g;
    }

    QDomElement stopElem = elem.firstChildElement();
    while (!stopElem.isNull()) {
        QGradientStop stop = loadGradientStop(stopElem);

        gradient.setColorAt(stop.first, stop.second);

        stopElem = stopElem.nextSiblingElement();
    }

    gradient.setSpread(spread);
    gradient.setCoordinateMode(mode);

    return gradient;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:43,代码来源:qtgradientutils.cpp

示例9: load

void StyleLoader::loadComposite(QRadialGradient& value)
{
	int coordinateMode;
	int spread;
	QPointF center;
	QPointF focal;
	double radius;
	QGradientStops stopPoints;

	load("coordinateMode", coordinateMode);
	load("spread", spread);
	load("centerPoint", center);
	load("focalPoint", focal);
	load("radius", radius);
	load("stopPoints", stopPoints);

	value = QRadialGradient(center, radius, focal);
	value.setSpread((QGradient::Spread) spread);
	value.setCoordinateMode((QGradient::CoordinateMode) coordinateMode);
	value.setStops(stopPoints);
}
开发者ID:JurajKubelka,项目名称:Envision,代码行数:21,代码来源:StyleLoader.cpp

示例10: setCompositionModeBounds

void BitmapImage::drawRect(QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
    int width = pen.width();
    setCompositionModeBounds(rectangle.adjusted(-width, -width, width, width).toRect(), true, cm);
    if (brush.style() == Qt::RadialGradientPattern)
    {
        QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
        gradient->setCenter(gradient->center() - mBounds.topLeft());
        gradient->setFocalPoint(gradient->focalPoint() - mBounds.topLeft());
    }
    if (!image()->isNull())
    {
        QPainter painter(image());
        painter.setCompositionMode(cm);
        painter.setRenderHint(QPainter::Antialiasing, antialiasing);
        painter.setPen(pen);
        painter.setBrush(brush);
        painter.drawRect(rectangle.translated(-mBounds.topLeft()));
        painter.end();
    }
    modification();
}
开发者ID:chchwy,项目名称:pencil2d,代码行数:22,代码来源:bitmapimage.cpp

示例11: QRadialGradient

void ConvertDialogTest::convert_filter_gradient()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
    filterGroupBox->setChecked(true);

    QRadioButton *filterGradientRadioButton = effectsScrollArea->filterGradientRadioButton;
    filterGradientRadioButton->setChecked(true);

    QRadialGradient gradient = QRadialGradient(QPoint(1, 2), 2.5);
    gradient.setColorAt(0.0, Qt::green);
    gradient.setColorAt(1.0, Qt::red);
    BrushFrame *filterBrushFrame = effectsScrollArea->filterBrushFrame;
    filterBrushFrame->setBrush(gradient);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFilterType(), int(Gradient));
    QCOMPARE(conf.getFilterBrush(), QBrush(gradient));
}
开发者ID:marek629,项目名称:SIR,代码行数:22,代码来源:ConvertDialogTest.cpp

示例12: extend

void BitmapImage::drawEllipse( QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
    int width = pen.width();
    extend( rectangle.adjusted(-width,-width,width,width).toRect() );
    if (brush.style() == Qt::RadialGradientPattern)
    {
        QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
        gradient->setCenter( gradient->center() - topLeft() );
        gradient->setFocalPoint( gradient->focalPoint() - topLeft() );
    }
    if (mImage != NULL && !mImage->isNull() )
    {
        QPainter painter(mImage);
        painter.setCompositionMode(cm);
        painter.setRenderHint(QPainter::Antialiasing, antialiasing);
        painter.setPen(pen);
        painter.setBrush(brush);
        //if (brush == Qt::NoBrush)
        painter.drawEllipse( rectangle.translated(-topLeft()) );
        painter.end();
    }
}
开发者ID:meiavy,项目名称:pencil-1,代码行数:22,代码来源:bitmapimage.cpp

示例13: gradient

void Point::paint ( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /*widget*/ )
{
  QRadialGradient gradient ( 0.0, 0.0, _radius );

  // If we are selected, use a lighter color.
  if ( option->state & QStyle::State_Sunken )
  {
    gradient.setColorAt ( 0, QColor ( Qt::yellow ).light ( 120 ) );
    gradient.setColorAt ( 1, QColor ( Qt::darkYellow ).light ( 120 ) );
    painter->setPen ( QPen ( Qt::red, 0 ) );
  }
  else
  {
    gradient.setColorAt ( 0, Qt::yellow );
    gradient.setColorAt ( 1, Qt::darkYellow );
    painter->setPen ( QPen ( Qt::black, 0 ) );
  }

  painter->setBrush ( gradient );

  const double diameter ( _radius * 2 );
  painter->drawEllipse ( -_radius, -_radius, diameter, diameter);
}
开发者ID:flyskyosg,项目名称:heliosvolume,代码行数:23,代码来源:Point.cpp

示例14: s

void Highlight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QColor pen_color = pen.color();
    painter->setPen(pen);
    if(time < total_time ){ //don't want to keep adding them past animation length
        int expected_num_rings = (int)ceil(frequency * time);
        if( expected_num_rings > rings.length()){
            rings.append(time);
        }
        //velocity= 200.0 - (time*total_time*2.0);//pretty cool
        //velocity= 200.0*(1.0-done_ratio);//pretty cool, about the same
        //frequency = 3.0*(1.0-done_ratio);//pretty cool
        for(int i=0; i<rings.length(); i++){
            //qreal dist = diameter + ( velocity * (time - rings.at(i)));
            qreal t = (time - rings.at(i));
            qreal dist = diameter + ( velocity * t ) + (0.5 * -5.0 * t*t);
            //qDebug() << "dist:" << dist << " outerDiameter:" << outerDiameter;

            QRectF s(x()-dist/2.0, y()-dist/2.0,dist,dist);
            QRectF r = mapRectFromScene(x()-dist/2.0, y()-dist/2.0,dist,dist);
            pen.setWidth(20.0+50.0* dist/outerDiameter);
            QRadialGradient radialGrad;
            radialGrad.setCenter(r.center());
            radialGrad.setFocalPoint(r.center());
            radialGrad.setCenterRadius(r.width()/2.0+pen.widthF()/2.0);
            radialGrad.setFocalRadius(r.width()/2.0-pen.widthF()/2.0);
            /* not entirely sure I get it, but I think focal radius
     * needs to be either the center of the pen or its inner edge
     * while center radius is the outer edge.
    */

            QColor green(0,255,0,255);
            QColor yellow(255,255,0,255);
            /*
            pen_color.setAlphaF(1.0-(dist/outerDiameter)); //surface waves don't inverse square
            */
            green.setAlphaF(1.0-(dist/outerDiameter));
            yellow.setAlphaF((1.0-(dist/outerDiameter)));

            radialGrad.setColorAt(.0, yellow );
            radialGrad.setColorAt( .5, green );
            radialGrad.setColorAt(1, yellow );

            brush = QBrush(radialGrad);
            pen.setBrush(brush);
            painter->setPen(pen);
            painter->drawEllipse(r);
        }

    }

}
开发者ID:GregGarber,项目名称:GoGoGo,代码行数:52,代码来源:highlight.cpp

示例15: xShadowOffset

void BoxStyle::unoptimizedPaint(QPainter* painter, int xOffset, int yOffset, int contentBoxWidth,
				int contentBoxHeight) const
{
	qreal x = xOffset;
	qreal y = yOffset;

	int outlineWidth = outline_.style()!=Qt::NoPen ? outline_.width() : 0;
	// Move the figure when using antialiasing. The outline will start at a pixel boundary. This makes it sharper.
	if ( painter->testRenderHint(QPainter::Antialiasing) || painter->testRenderHint(QPainter::HighQualityAntialiasing) )
		if ( outline().style() != Qt::NoPen)
		{
			x = xOffset + outlineWidth/2.0;
			y = yOffset + outlineWidth/2.0;
		}

	// Draw shadow
	if ( shadow() != Qt::NoBrush )
	{
		painter->setPen(Qt::NoPen);
		painter->setBrush(shadow());
		painter->drawPath(getRectanglePath(xOffset + xShadowOffset(), yOffset + yShadowOffset(),
				contentBoxWidth, contentBoxHeight));
	}

	// Draw box.
	painter->setPen(outline());

	// Set the brush and fix the gradient if needed.
	if ( background().style() == Qt::LinearGradientPattern
			&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
	{
		QLinearGradient g = *(static_cast<const QLinearGradient*> (background().gradient()));
		g.setStart(x + g.start().x(), y + g.start().y());
		g.setFinalStop(x + g.finalStop().x(), y + g.finalStop().y());
		painter->setBrush(g);

	}
	else if ( background().style()  == Qt::RadialGradientPattern
			&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
	{
		QRadialGradient g = *(static_cast<const QRadialGradient*> (background().gradient()));
		g.setCenter(x + g.center().x(), y + g.center().y());
		g.setFocalPoint(x + g.focalPoint().x(), y + g.focalPoint().y());
		painter->setBrush(g);
	}
	else
	{
		painter->setBrush(background());
	}

	painter->drawPath(getRectanglePath(x, y, contentBoxWidth - outlineWidth, contentBoxHeight - outlineWidth));
}
开发者ID:JurajKubelka,项目名称:Envision,代码行数:52,代码来源:BoxStyle.cpp


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