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


C++ QPainter::setOpacity方法代码示例

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


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

示例1: DrawMouseHoverRect

void MouseHoverable::DrawMouseHoverRect(QPainter &painter) const
{
    qreal old = painter.opacity();
    painter.setOpacity(m_alpha);
    painter.fillRect(m_composite->rect(), m_mouseOverColor);
    painter.setOpacity(old);
}
开发者ID:seanet7or,项目名称:customqtwidgets,代码行数:7,代码来源:mousehoverable.cpp

示例2: DrawBoat

//-----------------------------------------------------------------------------
//! 
//-----------------------------------------------------------------------------
void tBoatWidget::DrawBoat( QPainter& painter )
{
    painter.save();

    // Draw boat
    QColor color;
    if( tSystemSettings::Instance()->NightMode() )
    {
        color = Qt::white;
        painter.setOpacity(0.2);
    }
    else
    {
        color = Qt::black;
        painter.setOpacity(0.5);
    }

    painter.setPen(QPen(color, 6, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin));
    painter.translate(QPointF((width()/2.0)+0.5, 15.0));
    QPainterPath p;

    p.moveTo( 28, 146 );
    p.cubicTo(  34, 90,  44, 70, 0, 0 );
    p.cubicTo( -44, 70, -34, 90, -28, 146 );
    p.lineTo( 28, 146 );

    painter.drawPath(p);

    painter.restore();
}
开发者ID:dulton,项目名称:53_hero,代码行数:33,代码来源:tBoatWidget.cpp

示例3: drawTexture

void TextureMapperQt::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture)
{
    const BitmapTextureQt& textureQt = static_cast<const BitmapTextureQt&>(texture);
    QPainter* painter = m_painter;
    QPixmap pixmap = textureQt.m_pixmap;
    if (m_currentSurface)
        painter = &m_currentSurface->m_painter;

    if (maskTexture && maskTexture->isValid()) {
        const BitmapTextureQt* mask = static_cast<const BitmapTextureQt*>(maskTexture);
        QPixmap intermediatePixmap(pixmap.size());
        intermediatePixmap.fill(Qt::transparent);
        QPainter maskPainter(&intermediatePixmap);
        maskPainter.setCompositionMode(QPainter::CompositionMode_Source);
        maskPainter.drawPixmap(0, 0, pixmap);
        maskPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        maskPainter.drawPixmap(QRect(0, 0, pixmap.width(), pixmap.height()), mask->m_pixmap, mask->sourceRect());
        maskPainter.end();
        pixmap = intermediatePixmap;
    }

    const qreal prevOpacity = painter->opacity();
    const QTransform prevTransform = painter->transform();
    painter->setOpacity(opacity);
    painter->setTransform(matrix, true);
    painter->drawPixmap(targetRect, pixmap, FloatRect(textureQt.sourceRect()));
    painter->setTransform(prevTransform);
    painter->setOpacity(prevOpacity);
}
开发者ID:RasterCode,项目名称:wke,代码行数:29,代码来源:TextureMapperQt.cpp

示例4: paintCurrentFrame

void CanvasRenderer::paintCurrentFrame( QPainter& painter )
{

    for ( int i = 0; i < mObject->getLayerCount(); ++i )
    {
        Layer* layer = mObject->getLayer( i );

        if ( i == mLayerIndex || mOptions.nShowAllLayers != 1 )
        {
            painter.setOpacity( 1.0 );
        }
        else {
            painter.setOpacity( 0.8 );
        }


        if ( i == mLayerIndex || mOptions.nShowAllLayers > 0 ) {
            switch ( layer->type() )
            {
                case Layer::BITMAP: { paintBitmapFrame( painter, i, mFrameNumber ); break; }
                case Layer::VECTOR: { paintVectorFrame( painter, i, mFrameNumber ); break; }
                case Layer::CAMERA: break;
                case Layer::SOUND: break;
                default: Q_ASSERT( false ); break;
            }
        }
    }
}
开发者ID:GregorysonofCarl,项目名称:pencil,代码行数:28,代码来源:canvasrenderer.cpp

示例5: mask

void
PictureZoneEditor::onPaint(QPainter& painter, InteractionState const& interaction)
{
	painter.setWorldTransform(QTransform());
	painter.setRenderHint(QPainter::Antialiasing);

	if (!validateScreenPictureMask()) {
		schedulePictureMaskRebuild();
	} else {
		double const sn = sin(constants::DEG2RAD * m_pictureMaskAnimationPhase);
		double const scale = 0.5 * (sn + 1.0); // 0 .. 1
		double const opacity = 0.35 * scale + 0.15;

		QPixmap mask(m_screenPictureMask);

		{
			QPainter mask_painter(&mask);
			mask_painter.translate(-m_screenPictureMaskOrigin);
			paintOverPictureMask(mask_painter);
		}

		painter.setOpacity(opacity);
		painter.drawPixmap(m_screenPictureMaskOrigin, mask);
		painter.setOpacity(1.0);

		if (!m_pictureMaskAnimateTimer.isActive()) {
			m_pictureMaskAnimateTimer.start();
		}
	}
}
开发者ID:DikBSD,项目名称:STE,代码行数:30,代码来源:PictureZoneEditor.cpp

示例6: paintEvent

void SelectLocation::paintEvent(QPaintEvent *paintevent)
{
	QPainter painter;
	QPainterPath roundedrect;
	roundedrect.addRoundRect(this->rect(),20);
	
	painter.setOpacity(0.8);
	painter.fillPath(roundedrect,QColor(Qt::black));
	painter.setOpacity(1);
	
}
开发者ID:tvespasian,项目名称:weatherwidget2,代码行数:11,代码来源:SelectLocation.cpp

示例7: Render

void Timeline::Render(QPainter& painter)
{
    std::vector<QImage*> onions;

    for (size_t i = 0; i < mLayers.size(); ++i)
    {
        Layer* layer = mLayers[i];
        if (!layer->IsEnabled())
        {
            continue;
        }
        if (layer->GetType() == LayerTypeRaster)
        {
            QImage* img = mLayers[i]->GetImage(mFrameIndex);
            if (img)
            {
                if (mEditor->IsOnionEnabled() && mLayerIndex == (int)i)
                {
                    if (layer->GetType() == LayerTypeRaster && layer->IsOnionEnabled())
                    {
                        RasterLayer* l = (RasterLayer*)mLayers[i];
                        QImage* prev = l->GetImage(l->GetPrevImageIndex(mFrameIndex));
                        if(prev && prev != img)
                        {
                            onions.push_back(prev);
                        }
                        QImage* next = l->GetImage(l->GetNextImageIndex(mFrameIndex));
                        if(next && next != img)
                        {
                            onions.push_back(next);
                        }
                    }
                }

                painter.setOpacity(layer->GetOpacity() / 255.0f);
                painter.drawImage(0, 0, *img);
            }
        }
        else if (layer->GetType() == LayerTypeTrace)
        {
            TraceLayer* tl = (TraceLayer*)layer;
            tl->Render(painter);
        }
    }

    painter.setOpacity(0.25f);
    for (size_t i = 0; i < onions.size(); ++i)
    {
        painter.drawImage(0, 0, *onions[i]);
    }
}
开发者ID:walkerka,项目名称:anim_builder,代码行数:51,代码来源:timeline.cpp

示例8: drawChess

void ChessBoardWidget::drawChess(QPainter& painter)
{
    if(!showBoard)
        return;

    int i,j,step;
    bool flag;
    ChessBoard::ChessType type;

    painter.setFont(QFont("arial", cellHeight*0.35));
    painter.translate(gridLeft-cellWidth*0.5, gridTop-cellHeight*0.5);

    for(i=0;i<B_HEIGHT;++i)
    {
        for(j=0;j<B_WIDTH;++j)
        {
            type=showBoard->getGrid(i, j);
            if(type==ChessBoard::invalid)
                continue;
            painter.save();
            painter.translate(cellWidth*i, cellHeight*j);
            if(type==ChessBoard::empty)
            {
                if(historyStep==0&&!showBoard->isFinished()&&i==mouseX&&j==mouseY
                        &&showHint&&showBoard->checkMove(i, j, isNextBlack))
                {
                    painter.setOpacity(0.3);
                    painter.drawImage(QRectF(0, 0, cellWidth, cellHeight),
                                      isNextBlack?imgChessBlack[0]:imgChessWhite[0]);
                }
            }
            else
            {
                step=showBoard->getStep(i, j);
                flag=(i==currentX&&j==currentY);
                if(historyStep>0&&historyStep<step)
                    painter.setOpacity(0.2);
                painter.drawImage(QRectF(0, 0, cellWidth, cellHeight),
                                  type==ChessBoard::black?imgChessBlack[flag]:imgChessWhite[flag]);
                if(showGuide||historyStep>=step)
                {
                    painter.setPen(type==ChessBoard::black?"white":"black");
                    painter.drawText(QRectF(0, 0, cellWidth, cellHeight), Qt::AlignCenter,
                                     QString("%0").arg(step));
                }
            }
            painter.restore();
        }
    }

}
开发者ID:LuiCat,项目名称:Nogoer,代码行数:51,代码来源:chessboardwidget.cpp

示例9: paintTopBar

void ProfileWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) {
	if (animating() && _showing) {
		p.setOpacity(a_bgAlpha.current());
		p.drawPixmap(a_bgCoord.current(), 0, _bgAnimTopBarCache);
		p.setOpacity(a_alpha.current());
		p.drawPixmap(a_coord.current(), 0, _animTopBarCache);
	} else {
		p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over);
		p.drawPixmap(QPoint(st::topBarBackPadding.left(), (st::topBarHeight - st::topBarBackImg.height()) / 2), App::sprite(), st::topBarBackImg);
		p.setFont(st::topBarBackFont->f);
		p.setPen(st::topBarBackColor->p);
		p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.width() + st::topBarBackPadding.right(), (st::topBarHeight - st::titleFont->height) / 2 + st::titleFont->ascent, lang(peer()->chat ? lng_profile_group_info : lng_profile_info));
	}
}
开发者ID:Freyja-Folkvangr,项目名称:tdesktop,代码行数:14,代码来源:profilewidget.cpp

示例10: draw_bubble

void Bubble::draw_bubble(QPainter &painter) {
    QPen pen;
    pen.setWidth(stroke);
    pen.setBrush(colour);
    painter.setRenderHint(QPainter::HighQualityAntialiasing);
    painter.setPen(Qt::NoPen);
    painter.setBrush(colour);
    painter.setOpacity(opacity);
    painter.drawEllipse(QPointF(position()[0],position()[1]), r, r);
    painter.setPen(pen);
    painter.setBrush(Qt::NoBrush);
    painter.setOpacity(1.0);
    painter.drawEllipse(QPointF(position()[0],position()[1]), r, r);
}
开发者ID:ifknot,项目名称:flatland,代码行数:14,代码来源:bubble.cpp

示例11: drawUsingPainter

void PerspectivePixmap::drawUsingPainter(QPainter &painter)
{
    if (!mPixMap.isNull()) {
        qreal opOld = painter.opacity();
        QTransform transOld = painter.transform();
        QTransform trans = painter.transform();
        trans.scale(1, -1);
        painter.setTransform(trans);
        painter.setOpacity(0.8);
        painter.drawPixmap(-mXOffset / mScale, -mYOffset / mScale,
                           mPixMap.width() / mScale, mPixMap.height() / mScale, mPixMap);
        painter.setOpacity(opOld);
        painter.setTransform(transOld);
    }
}
开发者ID:wellrun,项目名称:rise_sdvp,代码行数:15,代码来源:perspectivepixmap.cpp

示例12: render

void QQuickShapeSoftwareRenderNode::render(const RenderState *state)
{
    if (m_sp.isEmpty())
        return;

    QSGRendererInterface *rif = m_item->window()->rendererInterface();
    QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));
    Q_ASSERT(p);

    const QRegion *clipRegion = state->clipRegion();
    if (clipRegion && !clipRegion->isEmpty())
        p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform

    p->setTransform(matrix()->toTransform());
    p->setOpacity(inheritedOpacity());

    for (const ShapePathRenderData &d : qAsConst(m_sp)) {
        if (d.hidden) {
            continue;
        }

//        QTransform oldTransform = p->transform();
//        p->setTransform(d.transform, true);

//        p->setOpacity(inheritedOpacity() * d.opacity);
        p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen);
        p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush);
        p->drawPath(d.path);

//        p->setTransform(oldTransform);
    }
}
开发者ID:Conntac,项目名称:lottie-qt,代码行数:32,代码来源:qquickshapesoftwarerenderer.cpp

示例13: paintContent

void LevelWinDialog::paintContent(QPainter &p)
{
  GamePanel::paintContent(p);

  p.setOpacity(1);
  p.setFont(gameStock->Font40);
  p.setPen(QPen(QColor(0x030055)));

  drawHCentered(p, 50, tr("Level %1 completed!").arg(level));

  p.setFont(gameStock->Font20);

  const int y30 = DY(40);

  const int x1 = DX(300), x2 = DX(380), x3 = DX(600);
  const int y1 = DY(250), y2 = DY(350);

  p.drawPixmap(x1,y1, gameStock->Clock);
  p.drawText(x3,y1+y30, QString("%1:%2").arg(time/60, 2, 10, QChar('0')).arg(time%60, 2, 10, QChar('0')));

  p.drawPixmap(x1,y2, gameStock->Score);
  p.drawText(x3,y2+y30, QString::number(score));

  p.setPen(QPen(Qt::black));
  p.drawText(x2,y1+y30, tr("Time left:"));
  p.drawText(x2,y2+y30, tr("Score:"));
}
开发者ID:SanskritFritz,项目名称:bubble-chains,代码行数:27,代码来源:gamedialogs.cpp

示例14: draw

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Circle::draw(QPainter& painter, const QPointF& startTile,
                  const QRect& viewport, const int& zoom) {

	if ( !isVisible() )
		return;

	QPointF coords;

	coord2screen(geoPosition(), coords, startTile, zoom);

	if ( !viewport.contains(coords.toPoint()) )
		coord2screen(geoPosition(), coords, startTile, zoom, true);

	setScreenPosition(coords);

	qreal yu = size().height() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000;
	qreal xu = size().width() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000;

	painter.save();
	painter.setPen(pen());
	painter.setBrush(brush());
	painter.setOpacity(opacity());
	painter.setRenderHint(QPainter::Antialiasing, isAntialiased());

	if ( isSizeInKm() )
		painter.drawEllipse(coords, xu, yu);
	else
		painter.drawEllipse(coords, size().width(), size().height());

	painter.restore();
}
开发者ID:salichon,项目名称:ipgp-addons,代码行数:32,代码来源:circle.cpp

示例15: drawDbLabels

void AudioGraphWidget::drawDbLabels(QPainter& p, const QRect &rect)
{
    int dbLabelCount = m_dbLabels.size();
    int textHeight = fontMetrics().ascent();
    int x = 0;
    int y = 0;
    int yline = 0;

    if (dbLabelCount == 0) return;

    int maxWidth = fontMetrics().width(QStringLiteral("-50"));
    // dB scale is vertical along the left side
    int prevY = height();
    QColor textCol = palette().text().color();
    QColor lineCol = textCol;
    p.setOpacity(0.8);
    lineCol.setAlpha(100);
    for (int i = 0; i < dbLabelCount; i++) {
        int value = m_dbLabels[i];
        QString label = QString::number(value);
        x = rect.left() + maxWidth - fontMetrics().width(label);
        yline = rect.bottom() - IEC_ScaleMax(value, m_maxDb) * rect.height();
        y = yline + textHeight / 2;
        if (y - textHeight < 0) {
            y = textHeight;
        }
        if (prevY - y >= 2) {
            p.setPen(textCol);
            p.drawText(x, y, label);
            p.setPen(lineCol);
            p.drawLine(rect.left() + maxWidth + 2, yline, rect.width(), yline);
            prevY = y - textHeight;
        }
    }
}
开发者ID:yiqideren,项目名称:kdenlive,代码行数:35,代码来源:audiographspectrum.cpp


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