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


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

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


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

示例1: clip

void GraphicsContext::clip(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();
    if (p->clipRegion().isEmpty())
        p->setClipRect(rect);
    else p->setClipRect(rect, Qt::IntersectClip);
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:10,代码来源:GraphicsContextQt.cpp

示例2: draw

void COverlayText::draw(QPainter& p, const QRect& viewport)
{
    if(highlight)
    {
        p.setBrush(Qt::white);
        p.setPen(QPen(Qt::blue,3));
    }
    else
    {
        p.setBrush(Qt::white);
        p.setPen(QPen(Qt::darkGray,2));
    }
    PAINT_ROUNDED_RECT(p,rect);

    if(selected == this)
    {
        p.setBrush(Qt::white);
        p.setPen(QPen(Qt::red, 3));
        PAINT_ROUNDED_RECT(p,rect);

        p.drawPixmap(rectMove, QPixmap(":/icons/iconMoveMap16x16.png"));
        p.drawPixmap(rectSize, QPixmap(":/icons/iconSize16x16.png"));
        p.drawPixmap(rectDel, QPixmap(":/icons/iconClear16x16.png"));
        p.drawPixmap(rectEdit, QPixmap(":/icons/iconEdit16x16.png"));
    }
    p.save();
    p.setClipRect(rectDoc);
    p.translate(rectDoc.topLeft());
    doc->drawContents(&p);
    p.restore();
}
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:31,代码来源:COverlayText.cpp

示例3: paint

void ClipboardProxyShape::paint(QPainter &painter, const KViewConverter &converter)
{
    painter.setClipRect(converter.documentToView(QRectF(QPointF(), size())));
    QSizeF nestedSize = m_child->size();
    QSizeF ourSize = size();
    const qreal scale = qMin(ourSize.width() / nestedSize.width(), ourSize.height() / nestedSize.height());
    if (scale != 1.0) {
        ZoomHandler zh;
        qreal x1;
        converter.zoom(&x1, &x1);
        zh.setAbsoluteZoom(x1 * scale);
        painter.save();
        m_child->paint(painter, zh);
        painter.restore();
        if (m_child->border())
            m_child->border()->paint(m_child, painter, zh);
    }
    else {
        painter.save();
        m_child->paint(painter, converter);
        painter.restore();
        if (m_child->border())
            m_child->border()->paint(m_child, painter, converter);
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:25,代码来源:ClipboardProxyShape.cpp

示例4: SetClip

void SurfaceImpl::SetClip(PRectangle rc)
{
    Q_ASSERT(painter);

    painter->setClipRect(
            QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:7,代码来源:PlatQt.cpp

示例5: drawAmplitude

void AFCWidget::drawAmplitude(QPainter & painter, QRectF rect)
{
	if(m_dB_points.size()<2) return;

	painter.setClipping(true);
	painter.setClipRect(rect);
	painter.setRenderHint(QPainter::Antialiasing, true);
	

	//amplitude
	painter.setPen( QPen(QColor(0, 0, 0, 255)) );

	float prev_x=m_dB_points.first().x();
	float prev_y=m_dB_points.first().y();

	float dB_range = m_dB2-m_dB1;

	foreach(QPointF p, m_dB_points){
//		QPointF p1( rect.left()+log_coef*log10(prev_x-m_freq1)/freq_range*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
//		QPointF p2( rect.left()+log_coef*log10(p.rx()-m_freq1)/freq_range*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );

		//linear scale
//		QPointF p1( rect.left()+(prev_x-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
//		QPointF p2( rect.left()+(p.rx()-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );

		//log scale
		QPointF p1( rect.left()+logFreq(prev_x)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
		QPointF p2( rect.left()+logFreq(p.rx())*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );


		if(p.x() <= m_freq2) painter.drawLine(p1, p2);
		prev_x = p.rx();
		prev_y = p.ry();
	}
开发者ID:mofr,项目名称:AmplitubeTime,代码行数:34,代码来源:afc_widget.cpp

示例6: renderFromTiledBackingStore

void QWebFramePrivate::renderFromTiledBackingStore(GraphicsContext* context, const QRegion& clip)
{
    ASSERT(frame->tiledBackingStore());

    if (!frame->view() || !frame->contentRenderer())
        return;

    QVector<QRect> vector = clip.rects();
    if (vector.isEmpty())
        return;

    QPainter* painter = context->platformContext();

    WebCore::FrameView* view = frame->view();
    
    int scrollX = view->scrollX();
    int scrollY = view->scrollY();
    context->translate(-scrollX, -scrollY);

    for (int i = 0; i < vector.size(); ++i) {
        const QRect& clipRect = vector.at(i);

        painter->save();
        
        QRect rect = clipRect.translated(scrollX, scrollY);
        painter->setClipRect(rect, Qt::IntersectClip);

        frame->tiledBackingStore()->paint(context, rect);

        painter->restore();
    }
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:32,代码来源:qwebframe.cpp

示例7: rect

void
PlayField::paintPainterClip(QPainter &paint, int x, int y, int w, int h) {
  QRect rect(x, y, w, h);

  paint.setClipRect(rect);
  paint.setClipping(true);
  paintPainter(paint, rect);
}
开发者ID:KDE,项目名称:ksokoban,代码行数:8,代码来源:PlayField.cpp

示例8: drawDecorations

void KisCanvasWidgetBase::drawDecorations(QPainter & gc, const QRect &updateWidgetRect) const
{
    gc.save();
    if (!m_d->canvas) {
        dbgFile<<"canvas doesn't exist, in canvas widget base!";
    }
    // Setup the painter to take care of the offset; all that the
    // classes that do painting need to keep track of is resolution
    gc.setRenderHint(QPainter::Antialiasing);
    gc.setRenderHint(QPainter::TextAntialiasing);

    // This option does not do anything anymore with Qt4.6, so don't reenable it since it seems to break display
    // http://www.archivum.info/[email protected]/2010-01/00481/Re:-(Qt-interest)-Is-QPainter::HighQualityAntialiasing-render-hint-broken-in-Qt-4.6.html
    // gc.setRenderHint(QPainter::HighQualityAntialiasing);

    gc.setRenderHint(QPainter::SmoothPixmapTransform);


    gc.save();
    gc.setClipRect(updateWidgetRect);

    QTransform transform = m_d->coordinatesConverter->flakeToWidgetTransform();
    gc.setTransform(transform);

    // Paint the shapes (other than the layers)
    m_d->canvas->globalShapeManager()->paint(gc, *m_d->viewConverter, false);

    // draw green selection outlines around text shapes that are edited, so the user sees where they end
    gc.save();
    QTransform worldTransform = gc.worldTransform();
    gc.setPen( Qt::green );

    Q_FOREACH (KoShape *shape, canvas()->shapeManager()->selection()->selectedShapes()) {
        if (shape->shapeId() == "ArtisticText" || shape->shapeId() == "TextShapeID") {
            gc.setWorldTransform(shape->absoluteTransformation(m_d->viewConverter) * worldTransform);
            KoShape::applyConversion(gc, *m_d->viewConverter);
            gc.drawRect(QRectF(QPointF(), shape->size()));
        }
    }
    gc.restore();

    // Draw text shape over canvas while editing it, that's needs to show the text selection correctly
    QString toolId = KoToolManager::instance()->activeToolId();
    if (toolId == "ArtisticTextTool" || toolId == "TextTool") {
        gc.save();
        gc.setPen(Qt::NoPen);
        gc.setBrush(Qt::NoBrush);
        Q_FOREACH (KoShape *shape, canvas()->shapeManager()->selection()->selectedShapes()) {
            if (shape->shapeId() == "ArtisticText" || shape->shapeId() == "TextShapeID") {
                KoShapePaintingContext  paintContext(canvas(), false);
                gc.save();
                gc.setTransform(shape->absoluteTransformation(m_d->viewConverter) * gc.transform());
                canvas()->shapeManager()->paintShape(shape, gc, *m_d->viewConverter, paintContext);
                gc.restore();
            }
        }
        gc.restore();
    }
开发者ID:IGLOU-EU,项目名称:krita,代码行数:58,代码来源:kis_canvas_widget_base.cpp

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

示例10: beginClip

void TextureMapperQt::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
{
    QPainter* painter = currentPainter();
    painter->save();
    QTransform prevTransform = painter->transform();
    painter->setTransform(matrix, false);
    painter->setClipRect(rect);
    painter->setTransform(prevTransform, false);
}
开发者ID:RasterCode,项目名称:wke,代码行数:9,代码来源:TextureMapperQt.cpp

示例11: paintEvent

void SignalPlot::paintEvent(QPaintEvent *event)
{
    QPainter painter;
    painter.begin(this);
    painter.setClipRect(event->rect());
    //painter.setRenderHint(QPainter::Antialiasing);
    painter.drawImage(QPoint(0,0), mBackground);
    drawSignal(painter);
    painter.end();
}
开发者ID:tz-lom,项目名称:BCIPlots,代码行数:10,代码来源:signalplot.cpp

示例12: print

void ItemDocument::print() {
	static KPrinter *printer = new KPrinter;

	if (! printer->setup(KTechlab::self()))
		return;

	// setup the printer.  with Qt, you always "print" to a
	// QPainter.. whether the output medium is a pixmap, a screen,
	// or paper
	QPainter p;
	p.begin(printer);

	// we let our view do the actual printing
	QPaintDeviceMetrics metrics(printer);

	// Round to 16 so that we cut in the middle of squares
	int w = metrics.width();
	w = (w & 0xFFFFFFF0) + ((w << 1) & 0x10);

	int h = metrics.height();
	h = (h & 0xFFFFFFF0) + ((h << 1) & 0x10);

	p.setClipping(true);
	p.setClipRect(0, 0, w, h, QPainter::CoordPainter);

	// Send off the painter for drawing
	m_canvas->setBackgroundPixmap(0);
	QRect bounding = canvasBoundingRect();

	unsigned int rows = (unsigned) std::ceil(double(bounding.height()) / double(h));
	unsigned int cols = (unsigned) std::ceil(double(bounding.width()) / double(w));

	int offset_x = bounding.x();
	int offset_y = bounding.y();

	for (unsigned row = 0; row < rows; ++row) {
		for (unsigned col = 0; col < cols; ++col) {
			if (row != 0 || col != 0)
				printer->newPage();

			QRect drawArea(offset_x + (col * w), offset_y + (row * h), w, h);

			m_canvas->drawArea(drawArea, & p);

			p.translate(-w, 0);
		}

		p.translate(w * cols, -h);
	}

	updateBackground();

	// and send the result to the printer
	p.end();
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:55,代码来源:itemdocument.cpp

示例13: paint

void PlatformScrollbar::paint(GraphicsContext* graphicsContext, const IntRect& damageRect)
{
    if (controlSize() != RegularScrollbar) {
        m_opt.state |= QStyle::State_Mini;
    } else {
        m_opt.state &= ~QStyle::State_Mini;
    }
    m_opt.orientation = (orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
    QStyle *s = QApplication::style();
    if (orientation() == HorizontalScrollbar) {
        m_opt.rect.setHeight(horizontalScrollbarHeight(controlSize()));
        m_opt.state |= QStyle::State_Horizontal;
    } else {
        m_opt.rect.setWidth(verticalScrollbarWidth(controlSize()));
        m_opt.state &= ~QStyle::State_Horizontal;
    }

    if (graphicsContext->paintingDisabled() || !m_opt.rect.isValid())
        return;

    QRect clip = m_opt.rect.intersected(damageRect);
    // Don't paint anything if the scrollbar doesn't intersect the damage rect.
    if (clip.isEmpty())
        return;

    QPainter *p = graphicsContext->platformContext();
    p->save();
    p->setClipRect(clip);
    m_opt.sliderValue = value();
    m_opt.sliderPosition = value();
    m_opt.pageStep = m_visibleSize;
    m_opt.singleStep = m_lineStep;
    m_opt.minimum = 0;
    m_opt.maximum = qMax(0, m_totalSize - m_visibleSize);
    if (m_pressedPart != QStyle::SC_None) {
        m_opt.activeSubControls = m_pressedPart;
    } else {
        m_opt.activeSubControls = m_hoveredPart;
    }

    const QPoint topLeft = m_opt.rect.topLeft();
#ifdef Q_WS_MAC
    QApplication::style()->drawComplexControl(QStyle::CC_ScrollBar, &m_opt, p, 0);
#else
    p->translate(topLeft);
    m_opt.rect.moveTo(QPoint(0, 0));

    // The QStyle expects the background to be already filled
    p->fillRect(m_opt.rect, m_opt.palette.background());

    QApplication::style()->drawComplexControl(QStyle::CC_ScrollBar, &m_opt, p, 0);
    m_opt.rect.moveTo(topLeft);
#endif
    p->restore();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:55,代码来源:PlatformScrollBarQt.cpp

示例14: paintEvent

void QImageWidget::paintEvent( QPaintEvent *e )
{
  if( !image.isNull() )
  {
    QPainter p;
    p.begin(this);
    p.setClipRect(e->rect());
    p.drawImage(QPoint(0,0), image);
    p.end();
  }
}
开发者ID:AugustXiao,项目名称:pvb,代码行数:11,代码来源:QImageWidget.cpp

示例15: paintEvent

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

	painter.begin(this);
	painter.setClipRect(event->rect());
	painter.setPen(Qt::NoPen);

	drawBackground(&painter);
	drawLines(&painter);
	drawBorders(&painter);
	drawEdges(&painter);
}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:13,代码来源:T_thumbSlider.cpp


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