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


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

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


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

示例1: drawCurves

void Plotter::drawCurves(QPainter& painter)
{
    noOfCurves = curveDataMap.count();
    QRect rect = this->printRect();
    double x=0,y=0;
    double width = rect.width() - 1;
    double height = rect.height() - 1;
    double yCount = maxY - minY;
    if(antiAliasing)
        painter.setRenderHints(QPainter::Antialiasing);
    painter.translate(Margin + 1,rect.bottom()-1);
    for(int i=0; i < noOfCurves ; i++)
    {
        QPolygonF polyline;
        QVector<double>* dataPtr = curveDataMap[i] ;
        for(int j = 0 ; j <= noOfPoints ; j++)
        {
            x = (width * j)/noOfPoints;
            y = (height * dataPtr->value(j))/yCount;
            polyline << QPoint(x,-y);
            //qDebug() << y;
        }
        qDebug() << x <<rect.right();
        painter.setPen(colorMap.value(i));
        painter.drawPolyline(polyline);

    }
}
开发者ID:Qt-Widgets,项目名称:uav,代码行数:28,代码来源:Plotter.cpp

示例2: paintEvent

void UIButton::paintEvent(QPaintEvent *event) {
  QPainter context;
  context.begin(this);


  QRect rect = contentsRect();

  rect.setX((contentsRect().width() - 128) / 2);
  rect.setY((contentsRect().height() - 128) / 2);
  rect.setWidth(128.0);
  rect.setHeight(128.0);

  if (isChecked()) {
    //rect = rect.adjusted(1, 1, -1, -1);
  }

  context.save();
  context.setRenderHints(QPainter::HighQualityAntialiasing |
                     QPainter::SmoothPixmapTransform |
                     QPainter::Antialiasing
                     );

  context.drawPixmap(rect,
                 ctx->m_icon_dict[ctx->m_current_action].pixmap(256, 256,
                 isEnabled() ? QIcon::Normal : QIcon::Disabled,
                 isChecked() ? QIcon::On : QIcon::Off));
  context.restore();
  context.end();
}
开发者ID:CasperDNSTeam,项目名称:casper,代码行数:29,代码来源:ui_button.cpp

示例3: paintGrid

void CanvasRenderer::paintGrid( QPainter& painter )
{
    int gridSize = mOptions.nGridSize;

    QRectF rect = painter.viewport();
    QRectF boundingRect = mViewTransform.inverted().mapRect( rect );
    int w = boundingRect.width();
    int h = boundingRect.height();

    //qDebug() << mViewTransform;
    //qDebug() << mViewTransform.inverted();

    int left = round100( boundingRect.left(), gridSize ) - gridSize;
    int right = round100( boundingRect.right(), gridSize ) + gridSize;
    int top = round100( boundingRect.top(), gridSize ) - gridSize;
    int bottom = round100( boundingRect.bottom(), gridSize ) + gridSize;
    
    QPen pen( Qt::lightGray );
    pen.setCosmetic( true );
    painter.setPen( pen );
    painter.setWorldMatrixEnabled( true );
    painter.setBrush( Qt::NoBrush );
    QPainter::RenderHints previous_renderhints = painter.renderHints();
    painter.setRenderHint( QPainter::Antialiasing, false );
    for ( int x = left; x < right; x += gridSize )
    {
        painter.drawLine( x, top, x, bottom );
    }

    for ( int y = top; y < bottom; y += gridSize )
    {
        painter.drawLine( left, y, right, y );
    }
    painter.setRenderHints(previous_renderhints);
}
开发者ID:GregorysonofCarl,项目名称:pencil,代码行数:35,代码来源:canvasrenderer.cpp

示例4: grabRect

void FreeRegionGrabber::grabRect()
{
    QPolygon pol = selection;
    if ( !pol.isEmpty() )
    {
	grabbing = true;

        int xOffset = pixmap.rect().x() - pol.boundingRect().x();
        int yOffset = pixmap.rect().y() - pol.boundingRect().y();
        QPolygon translatedPol = pol.translated(xOffset, yOffset);

        QPixmap pixmap2(pol.boundingRect().size());
        pixmap2.fill(Qt::transparent);

        QPainter pt;
        pt.begin(&pixmap2);
        if (pt.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
            pt.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
            pt.setBrush(Qt::black);
            pt.setPen(QPen(QBrush(Qt::black), 0.5));
            pt.drawPolygon(translatedPol);
            pt.setCompositionMode(QPainter::CompositionMode_SourceIn);
        } else {
            pt.setClipRegion(QRegion(translatedPol));
            pt.setCompositionMode(QPainter::CompositionMode_Source);
        }

        pt.drawPixmap(pixmap2.rect(), pixmap, pol.boundingRect());
        pt.end();

        emit freeRegionUpdated(pol);
        emit freeRegionGrabbed(pixmap2);
    }
}
开发者ID:KDE,项目名称:ksnapshot,代码行数:34,代码来源:freeregiongrabber.cpp

示例5: adoptPtr

// ********************************************************
ImageBufferData::ImageBufferData(const IntSize& size, bool accelerated)
{
    QPainter* painter = new QPainter;
    m_painter = adoptPtr(painter);

#if ENABLE(ACCELERATED_2D_CANVAS)
    if (accelerated) {
        m_impl = adoptPtr(new ImageBufferDataPrivateAccelerated(size));
    } else
#endif
        m_impl = adoptPtr(new ImageBufferDataPrivateUnaccelerated(size));

    if (!m_impl->paintDevice())
        return;
    if (!painter->begin(m_impl->paintDevice()))
        return;

    painter->setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
    QPen pen = painter->pen();
    pen.setColor(Qt::black);
    pen.setWidth(1);
    pen.setCapStyle(Qt::FlatCap);
    pen.setJoinStyle(Qt::SvgMiterJoin);
    pen.setMiterLimit(10);
    painter->setPen(pen);
    QBrush brush = painter->brush();
    brush.setColor(Qt::black);
    painter->setBrush(brush);
    painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
}
开发者ID:Metrological,项目名称:qtwebkit,代码行数:31,代码来源:ImageBufferQt.cpp

示例6: drawCoordinates

void My_Painter::drawCoordinates(QPainter &painter)
 {

     painter.setPen(QPen(Qt::black, 4, Qt::SolidLine));
     painter.setRenderHints(QPainter::Antialiasing, true);
     painter.drawPoint(10, 200);

     painter.setPen(Qt::black);

     painter.drawText(2 - xBoundingRect.width() / 2,
                      203 + xBoundingRect.height() / 2, tr("0") );

//---------------| t |------------------------------------------
     painter.drawLine(10, 10, 10, 200);
     painter.drawLine(10, 10, 15, 15);
     painter.drawLine(10, 10, 5, 15);
     painter.drawText( 2 - xBoundingRect.width() / 2,
                       5 + xBoundingRect.height() / 2, tr("t") );
//--------------------------------------------------------------

//---------------| n |------------------------------------------
     painter.drawLine(10, 200, 320, 200);
     painter.drawLine(320, 200, 315, 195);
     painter.drawLine(320, 200, 315, 205);
     painter.drawText(326 - yBoundingRect.width() / 2,
                      201 + yBoundingRect.height() / 2, tr("n"));
//--------------------------------------------------------------
 }
开发者ID:iit021702,项目名称:iit.021702,代码行数:28,代码来源:my_painter.cpp

示例7: paintEvent

			void PiecesWidget::paintEvent (QPaintEvent *e)
			{
				int s = Pieces_.size ();
				QPainter painter (this);
				painter.setRenderHints (QPainter::Antialiasing |
						QPainter::SmoothPixmapTransform);
				if (!s)
				{
					painter.setBackgroundMode (Qt::OpaqueMode);
					painter.setBackground (Qt::white);
					painter.end ();
					return;
				}
			
				QPixmap tempPicture (s, 1);
				QPainter tempPainter (&tempPicture);
				tempPainter.setPen (Qt::red);
				tempPainter.drawLine (0, 0, s, 0);
				QList<QPair<int, int> > trues = FindTrues (Pieces_);
				for (int i = 0; i < trues.size (); ++i)
				{
					QPair<int, int> pair = trues.at (i);
			
					tempPainter.setPen (Qt::darkGreen);
					tempPainter.drawLine (pair.first, 0, pair.second, 0);
				}
				tempPainter.end ();
			
				painter.drawPixmap (QRect (0, 0, width (), height ()), tempPicture);
				painter.end ();
			
				e->accept ();
			}
开发者ID:Apkawa,项目名称:leechcraft,代码行数:33,代码来源:pieceswidget.cpp

示例8: paint

void KarbonCalligraphyTool::paint(QPainter &painter, const KoViewConverter &converter)
{
    if (m_selectedPath) {
        painter.save();
        painter.setRenderHints(QPainter::Antialiasing, false);
        painter.setPen(Qt::red);   // TODO make configurable
        QRectF rect = m_selectedPath->boundingRect();
        QPointF p1 = converter.documentToView(rect.topLeft());
        QPointF p2 = converter.documentToView(rect.bottomRight());
        painter.drawRect(QRectF(p1, p2));
        painter.restore();
    }

    if (!m_shape) {
        return;
    }

    painter.save();

    painter.setTransform(m_shape->absoluteTransformation(&converter) *
                         painter.transform());
    KoShapePaintingContext paintContext; //FIXME
    m_shape->paint(painter, converter, paintContext);

    painter.restore();
}
开发者ID:ChrisJong,项目名称:krita,代码行数:26,代码来源:KarbonCalligraphyTool.cpp

示例9: paintChart

void LinearChart::paintChart( QPainter& painter ) {

      painter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
      this->paintAxis(painter);
      QList<int> orderedColumns = this->calculateColumnsOrder();
      foreach( int c, orderedColumns ) {
        this->paintValues( painter, c );
      }
开发者ID:Zugzwangs,项目名称:Eternal-Deck-Builder,代码行数:8,代码来源:linearchart.cpp

示例10: paint

void QSGPainterNode::paint()
{
    QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect;

    QPainter painter;
    if (m_actualRenderTarget == QQuickPaintedItem::Image) {
        if (m_image.isNull())
            return;
        painter.begin(&m_image);
    } else {
        if (!m_gl_device) {
            m_gl_device = new QOpenGLPaintDevice(m_fboSize);
            m_gl_device->setPaintFlipped(true);
        }

        if (m_multisampledFbo)
            m_multisampledFbo->bind();
        else
            m_fbo->bind();

        painter.begin(m_gl_device);
    }

    if (m_smoothPainting) {
        painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
    }

    painter.scale(m_contentsScale, m_contentsScale);

    QRect sclip(qFloor(dirtyRect.x()/m_contentsScale),
                qFloor(dirtyRect.y()/m_contentsScale),
                qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)),
                qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale)));

    if (!m_dirtyRect.isNull())
        painter.setClipRect(sclip);

    painter.setCompositionMode(QPainter::CompositionMode_Source);
    painter.fillRect(sclip, m_fillColor);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

    m_item->paint(&painter);
    painter.end();

    if (m_actualRenderTarget == QQuickPaintedItem::Image) {
        m_texture->setImage(m_image);
        m_texture->setDirtyRect(dirtyRect);
    } else if (m_multisampledFbo) {
        QOpenGLFramebufferObject::blitFramebuffer(m_fbo, dirtyRect, m_multisampledFbo, dirtyRect);
    }

    if (m_multisampledFbo)
        m_multisampledFbo->release();
    else if (m_fbo)
        m_fbo->release();

    m_dirtyRect = QRect();
}
开发者ID:tizenorg,项目名称:platform.upstream.qtdeclarative,代码行数:58,代码来源:qsgpainternode.cpp

示例11: paintEvent

void ConnectionStatusWidget::paintEvent(QPaintEvent *){
  QPainter myPainter;
  myPainter.begin(this);
  myPainter.setRenderHints(QPainter::Antialiasing);
  myPainter.setBrush(diodeColor);
  int radious = qMin(height(), width())/2 -1;
  if(radious<1 )
    radious = 1;
  myPainter.drawEllipse(QPoint(width()/2,height()/2),radious,radious);
}
开发者ID:Haskis,项目名称:Skarabeusz_URC,代码行数:10,代码来源:connectionstatuswidget.cpp

示例12: renderText

void GLC_Viewport::renderText(const GLC_Point3d& point, const QString &text, const QColor &color, const QFont &font)
{
    m_TextRenderingCollection.clear();
    if (!text.isEmpty())
    {
        QFontMetrics fontMetrics(font);
        const double width= fontMetrics.width(text);
        const double height= fontMetrics.height();

        // Compute the ratio betwwen screen and world
        const GLC_Matrix4x4 invertedViewMatrix(GLC_Context::current()->modelViewMatrix().rotationMatrix().invert());
        const GLC_Vector2d projectedPoint1(project(point, false));
        const GLC_Vector3d vector(invertedViewMatrix * GLC_Vector3d(0.0, height, 0.0));
        const GLC_Vector2d projectedPoint2(project((point + vector), false));
        const double ratio= height / (projectedPoint2 - projectedPoint1).length();

        QPixmap pixmap(width, height);
        pixmap.fill(Qt::transparent);
        QPainter painter;

        painter.begin(&pixmap);
        painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing);
        painter.setFont(font);
        painter.setPen(color);
        painter.drawText(0, fontMetrics.ascent(), text);
        painter.end();

        QImage image= pixmap.toImage();

        GLC_Texture *pTexture= new GLC_Texture(image);
        GLC_Material* pMaterial= new GLC_Material(Qt::black);
        pMaterial->setTexture(pTexture);
        pMaterial->setOpacity(0.99);

        GLC_3DViewInstance rectangle= GLC_Factory::instance()->createRectangle(width, height);

        GLC_Matrix4x4 scaleMatrix;
        scaleMatrix.setMatScaling(ratio, ratio, ratio);
        rectangle.setMatrix(scaleMatrix);
        rectangle.multMatrix(invertedViewMatrix);
        rectangle.multMatrix(GLC_Matrix4x4(point));
        rectangle.geomAt(0)->addMaterial(pMaterial);
        m_TextRenderingCollection.add(rectangle);

        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glDisable(GL_DEPTH_TEST);
        m_TextRenderingCollection.render(0, glc::TransparentRenderFlag);
        glEnable(GL_DEPTH_TEST);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        m_TextRenderingCollection.clear();
    }
}
开发者ID:JasonWinston,项目名称:GLC_lib,代码行数:52,代码来源:glc_viewport.cpp

示例13: paintIndentMarker

void KateRenderer::paintIndentMarker(QPainter &paint, uint x, uint y /*row*/)
{
  QPen penBackup( paint.pen() );
  QPen myPen(config()->indentationLineColor());
  static const QVector<qreal> dashPattern = QVector<qreal>() << 1 << 1;
  myPen.setDashPattern(dashPattern);
  if (y % 2)
    myPen.setDashOffset(1);
  paint.setPen(myPen);

  const int height = fontHeight();
  const int top = 0;
  const int bottom = height-1;

  QPainter::RenderHints renderHints = paint.renderHints();
  paint.setRenderHints(renderHints, false);

  paint.drawLine(x + 2, top, x + 2, bottom);

  paint.setRenderHints(renderHints, true);

  paint.setPen( penBackup );
}
开发者ID:fluxer,项目名称:kde-baseapps,代码行数:23,代码来源:katerenderer.cpp

示例14: paintEvent

void MeshWidgetChart::paintEvent(QPaintEvent* event)
{
    QWidget::paintEvent(event);
    QPainter painter;

    painter.begin(this);

    setFont(font());
    painter.setRenderHints(QPainter::TextAntialiasing);
    painter.drawText(m_titleRect, Qt::AlignCenter, m_title);

    ChartItemList items = m_topItem.items();
    double maxVal = 0;
    foreach (MeshChartItem* item, items) { maxVal = std::max(maxVal, item->value()); }
开发者ID:denis-itskovich,项目名称:wifi-mesh,代码行数:14,代码来源:MeshWidgetChart.cpp

示例15: draw

void PHISurfaceEffect::draw( QPainter *painter )
{
    /*
    QPoint offset;
    QPixmap pixmap;
    if ( sourceIsPixmap() ) {
    // No point in drawing in device coordinates (pixmap will be scaled anyways).
        pixmap=sourcePixmap( Qt::LogicalCoordinates, &offset );
    } else {
    // Draw pixmap in device coordinates to avoid pixmap scaling;
        pixmap=sourcePixmap( Qt::DeviceCoordinates, &offset );
        painter->setWorldTransform( QTransform() );
    }

    QImage img=pixmap.toImage();
    img=PHI::getSurfacedImage( img, _yOff, _size );
    painter->drawImage( offset, img );
*/
    QRectF brect=sourceBoundingRect( Qt::LogicalCoordinates );
    QImage img( static_cast<int>(brect.width()+1), static_cast<int>(brect.height()+_size+_yOff),
        QImage::Format_ARGB32_Premultiplied );
    QPainter pixPainter;
    pixPainter.begin( &img );

    pixPainter.setRenderHints( painter->renderHints() );
    pixPainter.setCompositionMode( QPainter::CompositionMode_Clear );
    pixPainter.fillRect( 0., 0., brect.width()+1., brect.height()+_size+_yOff+1, Qt::transparent );
    pixPainter.setCompositionMode( QPainter::CompositionMode_SourceOver );
    drawSource( &pixPainter );

    QTransform t;
    t.rotate( 180., Qt::XAxis );
    t.translate( 0., (-brect.height()*2.)-_yOff+1. );
    pixPainter.setTransform( t );
    drawSource( &pixPainter );

    pixPainter.resetTransform();
    pixPainter.translate( 0., brect.height()+_yOff );
    QLinearGradient gradient( 0., 0., 0., 1.0 );
    gradient.setColorAt( 0., QColor( 0, 0, 0, 220 ) );
    gradient.setColorAt( 0.78, QColor( 0, 0, 0, 30 ) );
    gradient.setColorAt( 1., Qt::transparent );
    gradient.setCoordinateMode( QGradient::ObjectBoundingMode );

    pixPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
    pixPainter.fillRect( 0., 0., brect.width()+1, _size, gradient );
    pixPainter.end();
    painter->drawImage( 0, 0, img );
}
开发者ID:TheAppsDude,项目名称:phisketeer,代码行数:49,代码来源:phieffects.cpp


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