本文整理汇总了C++中QPainter::fillPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::fillPath方法的具体用法?C++ QPainter::fillPath怎么用?C++ QPainter::fillPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::fillPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawThrusterIcon
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrusterIcon( QPainter& painter, int yPos )
{
painter.save();
QColor thrusterColor = tSystemSettings::Instance()->NightMode() ? Qt::darkGray : Qt::black;
int w_2 = width()/2;
painter.translate( QPointF(w_2, yPos) );
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setPen( QPen(thrusterColor, 1) );
painter.drawLine(-5,0,5,0);
painter.drawLine(0,-5,0,5);
painter.setRenderHint(QPainter::Antialiasing, true);
for(int i=0;i<4;i++)
{
painter.save();
painter.translate(QPointF(0.5, 0.5));
painter.rotate(i*90);
QPainterPath p1;
p1.lineTo( QPointF( -4.5, -13 ) );
p1.lineTo( QPointF( 4.5, -13 ) );
painter.fillPath( p1, thrusterColor );
painter.restore();
}
painter.setPen( QPen(thrusterColor, 3.5) );
painter.drawEllipse(QPointF(0.5,0.5),13.0, 13.0);
painter.restore();
}
示例2: fillPolygon
void BoardView::fillPolygon(QPainter& painter, float cellSize)
{
const QColor firstColor(Settings::firstPointColor());
const QColor secondColor(Settings::secondPointColor());
const auto& polygonVector = m_model->polygons();
const QBrush firstPolyBrush(firstColor,
BrushComboDelegate::getBrushStyle(Settings::firstFillStyle()));
const QBrush secondPolyBrush(secondColor,
BrushComboDelegate::getBrushStyle(Settings::secondFillStyle()));
for (Polygon_ptr polygon : polygonVector)
{
QPolygon qPoly;
for(const QPoint& point : polygon->points())
{
const QPoint& newPoint = point + QPoint{1, 1};
qPoly << QPoint(newPoint) * cellSize;
}
QPainterPath path;
path.addPolygon(qPoly);
painter.fillPath(path, polygon->owner() == Owner::FIRST
? firstPolyBrush
: secondPolyBrush);
}
}
示例3: paintEvent
void PanelRadar::paintEvent(QPaintEvent* event) {
const qreal scale0 = 0.14644660940672623779957781894758;
const qreal scale1 = (1.0 - scale0);
PanelWidget::paintEvent(event);
QPainter p;
p.begin(this);
setMargins(&p);
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::TextAntialiasing, true);
QPen pen = p.pen();
pen.setWidth(1);
p.setPen(QColor("black"));
QPainterPath path;
qreal rx = p.device()->width();
qreal ry = p.device()->height();
QPointF point(0.5 * rx, 0.5 * ry);
path.addEllipse(point, 0.50 * rx, 0.50 * ry);
p.fillPath(path, QColor("white"));
path.addEllipse(point, 0.25 * rx, 0.25 * ry);
p.drawPath(path);
p.drawLine(0, 0.5 * ry, rx, 0.5 * ry);
p.drawLine(0.5 * rx, 0, 0.5 * rx, ry);
p.drawLine(rx * scale0 + 1, ry * scale0 + 1, rx * scale1 - 1, ry * scale1 - 1);
p.drawLine(rx * scale0 + 1, ry * scale1 - 1, rx * scale1 - 1, ry * scale0 + 1);
drawItems(&p);
p.end();
}
示例4: DrawThrustArrow
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrustArrow( QPainter& painter, int value, int yPos )
{
painter.save();
painter.translate( QPointF(width()/2, yPos+0.5) );
int minValue = 10;
int headLength = 24;
int valuePix = value/2;
if( valuePix < 0 )
valuePix = -valuePix;
int s = (value > 0) ? 1 : -1;
QColor arrowColor = (value > 0) ? QColor(0,188,0) : Qt::red;
QColor grad1Color = QColor(7,131,255,255);
QColor grad2Color = QColor(7,131,255,0);
if( tSystemSettings::Instance()->NightMode() )
{
arrowColor = arrowColor.darker();
grad1Color = grad1Color.darker();
}
// Draw arrow
QPainterPath path;
path.moveTo( 0, -10 );
path.lineTo( s*(minValue + valuePix), -10);
path.lineTo( s*(minValue + valuePix), -15 );
path.lineTo( s*(minValue + valuePix + headLength), 0 );
path.lineTo( s*(minValue + valuePix), 15 );
path.lineTo( s*(minValue + valuePix), 10 );
path.lineTo( 0, 10 );
painter.fillPath( path, arrowColor );
// Draw vacuum
QGradient grad = QLinearGradient( QPointF(0,0), QPointF(-s*40,0) );
grad.setColorAt(0.0, grad1Color );
grad.setColorAt(1.0, grad2Color );
QPainterPath p2;
p2.moveTo( 0, -12 );
p2.lineTo( -s*40, -21 );
p2.lineTo( -s*40, 21 );
p2.lineTo( 0, 12 );
painter.fillPath( p2, grad );
painter.restore();
}
示例5: pen
void
drawCompositedPopup( QWidget* widget,
const QPainterPath& outline,
const QColor& lineColor,
const QBrush& backgroundBrush,
qreal opacity )
{
bool compositingWorks = true;
#if defined(Q_WS_WIN) //HACK: Windows refuses to perform compositing so we must fake it
compositingWorks = false;
#elif defined(Q_WS_X11)
if ( !QX11Info::isCompositingManagerRunning() )
compositingWorks = false;
#endif
QPainter p;
QImage result;
if ( compositingWorks )
{
p.begin( widget );
p.setRenderHint( QPainter::Antialiasing );
p.setBackgroundMode( Qt::TransparentMode );
}
else
{
result = QImage( widget->rect().size(), QImage::Format_ARGB32_Premultiplied );
p.begin( &result );
p.setCompositionMode( QPainter::CompositionMode_Source );
p.fillRect( result.rect(), Qt::transparent );
p.setCompositionMode( QPainter::CompositionMode_SourceOver );
}
QPen pen( lineColor );
pen.setWidth( 2 );
p.setPen( pen );
p.drawPath( outline );
p.setOpacity( opacity );
p.fillPath( outline, backgroundBrush );
p.end();
if ( !compositingWorks )
{
QPainter finalPainter( widget );
finalPainter.setRenderHint( QPainter::Antialiasing );
finalPainter.setBackgroundMode( Qt::TransparentMode );
finalPainter.drawImage( 0, 0, result );
widget->setMask( QPixmap::fromImage( result ).mask() );
}
#ifdef QT_MAC_USE_COCOA
// Work around bug in Qt/Mac Cocoa where opening subsequent popups
// would incorrectly calculate the background due to it not being
// invalidated.
SourceTreePopupHelper::clearBackground( widget );
#endif
}
示例6: virt_to_display
void
Thumbnail::paintOverImage(
QPainter& painter, QTransform const& image_to_display,
QTransform const& thumb_to_display)
{
// We work in display coordinates because we want to be
// pixel-accurate with what we draw.
painter.setWorldTransform(QTransform());
QTransform const virt_to_display(virtToThumb() * thumb_to_display);
QRectF const inner_rect(virt_to_display.map(m_virtContentRect).boundingRect());
// We extend the outer rectangle because otherwise we may get white
// thin lines near the edges due to rounding errors and the lack
// of subpixel accuracy. Doing that is actually OK, because what
// we paint will be clipped anyway.
QRectF const outer_rect(
virt_to_display.map(m_virtOuterRect).boundingRect().adjusted(-1.0, -1.0, 1.0, 1.0)
);
QPainterPath outer_outline;
outer_outline.addPolygon(PolygonUtils::round(outer_rect));
QPainterPath content_outline;
content_outline.addPolygon(PolygonUtils::round(inner_rect));
painter.setRenderHint(QPainter::Antialiasing, true);
QColor bg_color;
QColor fg_color;
if (m_params.alignment().isNull()) {
// "Align with other pages" is turned off.
// Different color is useful on a thumbnail list to
// distinguish "safe" pages from potentially problematic ones.
bg_color = QColor(0x58, 0x7f, 0xf4, 70);
fg_color = QColor(0x00, 0x52, 0xff);
} else {
bg_color = QColor(0xbb, 0x00, 0xff, 40);
fg_color = QColor(0xbe, 0x5b, 0xec);
}
// Draw margins.
painter.fillPath(outer_outline.subtracted(content_outline), bg_color);
QPen pen(fg_color);
pen.setCosmetic(true);
pen.setWidthF(1.0);
painter.setPen(pen);
painter.setBrush(Qt::NoBrush);
// toRect() is necessary because we turn off antialiasing.
// For some reason, if we let Qt round the coordinates,
// the result is slightly different.
painter.drawRect(inner_rect.toRect());
}
示例7: 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);
}
示例8:
void Shape2DRectangle::drawShape(QPainter& painter) const
{
QRectF drawRect = m_boundingRect.toQRectF();
painter.drawRect(drawRect);
if (m_fill_color != QColor())
{
QPainterPath path;
path.addRect(drawRect);
painter.fillPath(path,m_fill_color);
}
}
示例9:
void KoShapeStroke::Private::paintBorder(KoShape *shape, QPainter &painter, const QPen &pen) const
{
if (!pen.isCosmetic()) {
KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
if (pathShape) {
QPainterPath path = pathShape->pathStroke(pen);
painter.fillPath(path, pen.brush());
return;
}
painter.strokePath(shape->outline(), pen);
}
}
示例10: fillPath
void GraphicsContext::fillPath()
{
if (paintingDisabled())
return;
QPainter *p = m_data->p();
QPainterPath path = m_data->currentPath;
switch (m_common->state.fillColorSpace) {
case SolidColorSpace:
if (fillColor().alpha())
p->fillPath(path, p->brush());
break;
case PatternColorSpace:
p->fillPath(path, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
break;
case GradientColorSpace:
p->fillPath(path, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
break;
}
}
示例11: Draw
void CMeteorite::Draw( QPainter &painter, const float freq_tick )
{
painter.setPen( QPen( meteo_clr, 1 ) );
float tx = 0, ty = 0;
getTickCoords( freq_tick, tx, ty );
QPolygon m_tmp_bd( m_body );
m_tmp_bd.translate( tx, ty );
painter.drawPolygon( m_tmp_bd );
QPainterPath pt;
pt.addPolygon( m_tmp_bd );
painter.fillPath( pt, QBrush( Qt::black ));
painter.fillPath( pt, QBrush( meteo_clr, Qt::Dense2Pattern ));
}
示例12: drawingContext
void CanvasRenderingContext2D::fill()
{
GraphicsContext* c = drawingContext();
if (!c)
return;
// FIXME: Do this through platform-independent GraphicsContext API.
#if PLATFORM(CG)
CGContextBeginPath(c->platformContext());
CGContextAddPath(c->platformContext(), state().m_path.platformPath());
if (!state().m_path.isEmpty())
willDraw(CGContextGetPathBoundingBox(c->platformContext()));
if (state().m_fillStyle->gradient()) {
// Shading works on the entire clip region, so convert the current path to a clip.
c->save();
CGContextClip(c->platformContext());
CGContextDrawShading(c->platformContext(), state().m_fillStyle->gradient()->platformShading());
c->restore();
} else {
if (state().m_fillStyle->pattern())
applyFillPattern();
CGContextFillPath(c->platformContext());
}
#elif PLATFORM(QT)
QPainterPath* path = state().m_path.platformPath();
QPainter* p = static_cast<QPainter*>(c->platformContext());
willDraw(path->controlPointRect());
if (state().m_fillStyle->gradient()) {
p->fillPath(*path, QBrush(*(state().m_fillStyle->gradient()->platformShading())));
} else {
if (state().m_fillStyle->pattern())
applyFillPattern();
p->fillPath(*path, p->brush());
}
#endif
clearPathForDashboardBackwardCompatibilityMode();
}
示例13: drawPolygon
void drawPolygon(QPainter &p, const std::vector<QPointF> &points, bool fill,
const QColor colorFill, const QColor colorLine) {
if (points.size() == 0) return;
p.setPen(colorLine);
QPolygonF E0Polygon;
int i = 0;
for (i = 0; i < (int)points.size(); i++) E0Polygon << QPointF(points[i]);
E0Polygon << QPointF(points[0]);
QPainterPath E0Path;
E0Path.addPolygon(E0Polygon);
if (fill) p.fillPath(E0Path, QBrush(colorFill));
p.drawPath(E0Path);
}
示例14: mdp
/// Draw marker as a diamond
void PeakMarker2D::drawDiamond(QPainter& painter)const
{
QPointF dp = origin();
QPointF mdp(-dp.x(),-dp.y());
// draw a diamond as a square rotated by 45 degrees
painter.save();
painter.translate(dp);
painter.rotate(45);
painter.translate(mdp);
QPainterPath path;
path.addRect(m_boundingRect.toQRectF());
painter.fillPath(path,m_color);
painter.restore();
}
示例15: painter
void PanWidget::
paintEvent ( QPaintEvent * event )
{
QPainter painter (this);
painter.setRenderHints (QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
painter.fillPath (path_, QColor(220,220,220,200));
painter.strokePath (path_, QPen(
QColor(100,100,100,200),
hasFocus () ? 1.6 : .8,
Qt::SolidLine,
Qt::RoundCap,
Qt::RoundJoin));
QWidget::paintEvent(event);
}