本文整理汇总了C++中QPainter::setRenderHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::setRenderHint方法的具体用法?C++ QPainter::setRenderHint怎么用?C++ QPainter::setRenderHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::setRenderHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawEndPos
/**
* @brief Draw the end point.
* @param painter
*/
void RenderArea::drawEndPos(QPainter &painter)
{
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::black);
painter.setBrush(QBrush(Qt::blue));
painter.drawEllipse(END_POS_X - BOT_RADIUS, END_POS_Y - BOT_RADIUS, 2 * BOT_RADIUS, 2 * BOT_RADIUS);
painter.restore();
}
示例2: createBall
void TurnAndBank::createBall(void){
QImage _glassImage = QImage(QSize(800,800), QImage::Format_ARGB32);
_glassImage.fill(0x00ffffff);
QPainter p;
p.setRenderHint(QPainter::Antialiasing, true);
p.begin(&_glassImage);
p.translate(400, 400);
// QLinearGradient gradient(0,101,0,199);
// gradient.setColorAt(0, SKYBLUE);
// gradient.setColorAt(1, GROUNDBROWN);
QRadialGradient gradient(0,-4500, 4750, 0, 30000);
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::green);
gradient.setSpread(QGradient::ReflectSpread);
QBrush gbrush(gradient);
p.setBrush(gbrush);
// p.drawRect(-350, 120, 700, 150);
QPainterPath pathBottom;
pathBottom.moveTo(-310, 150);
pathBottom.arcTo(-2500+50,-3830-1000,5000,5000, -96, 12);
//pathBottom.lineTo(310, 250);
pathBottom.arcTo(-2000,-3700,4000,4000, -81, -18);
//pathBottom.lineTo(-310, 150);
// pathBottom.lineTo(-240,0);
//pathBottom.arcTo(-240,-240,480,480, 180, 180);
// p.setPen(QPen(QColor(79, 106, 25), 0, Qt::SolidLine,
// Qt::FlatCap, Qt::MiterJoin));
p.setPen(QPen(Qt::white, 4, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
p.setPen(Qt::NoPen);
p.setBrush(gbrush);
// p.setBrush(GROUNDBROWN);
p.drawPath(pathBottom);
p.setBrush(Qt::black);
p.setPen(QPen(Qt::black, 4, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
p.drawLine(-50,170, -50, 300);
p.drawLine(50,170, 50, 300);
p.end();
_ball = QPixmap::fromImage(_glassImage, Qt::AutoColor);
}
示例3: paint
void ConnectionTool::paint(QPainter &painter, const KoViewConverter &converter)
{
// get the correctly sized rect for painting handles
QRectF handleRect = handlePaintRect(QPointF());
painter.setRenderHint(QPainter::Antialiasing, true);
if (m_currentStrategy) {
painter.save();
m_currentStrategy->paint(painter, converter);
painter.restore();
}
QList<KoShape*> shapes = canvas()->shapeManager()->shapes();
for (QList<KoShape*>::const_iterator end = shapes.constBegin(); end != shapes.constEnd(); ++end) {
KoShape* shape = *end;
if (!dynamic_cast<KoConnectionShape*>(shape)) {
// only paint connection points of textShapes not inside a tos container and other shapes
if (shape->shapeId() == TextShape_SHAPEID && dynamic_cast<KoTosContainer*>(shape->parent())) continue;
painter.save();
painter.setPen(Qt::black);
QTransform transform = shape->absoluteTransformation(0);
KoShape::applyConversion(painter, converter);
// Draw all the connection points of the shape
KoConnectionPoints connectionPoints = shape->connectionPoints();
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
if (shape == findNonConnectionShapeAtPosition(transform.map(cp.value().position)) ) {
handleRect.moveCenter(transform.map(cp.value().position));
painter.setBrush(cp.key() == m_activeHandle && shape == m_currentShape ?
Qt::red : Qt::white);
painter.drawRect(handleRect);
}
}
painter.restore();
}
}
// paint connection points or connection handles depending
// on the shape the mouse is currently
if (m_currentShape && m_editMode == EditConnection) {
KoConnectionShape *connectionShape = dynamic_cast<KoConnectionShape*>(m_currentShape);
if (connectionShape) {
int radius = handleRadius()+1;
int handleCount = connectionShape->handleCount();
for(int i = 0; i < handleCount; ++i) {
painter.save();
painter.setPen(Qt::blue);
painter.setBrush(i == m_activeHandle ? Qt::red : Qt::white);
painter.setTransform(connectionShape->absoluteTransformation(&converter) * painter.transform());
connectionShape->paintHandle(painter, converter, i, radius);
painter.restore();
}
}
}
}
示例4: 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
}
示例5: paintEvent
void MapGrid::paintEvent(QPaintEvent *event)
{
QPainter painter;
painter.begin(this);
painter.setRenderHint(QPainter::Antialiasing);
gesti->paint(&painter,event,elapsed);
// painter.end();
}
示例6: paintDecorations
void DivineProportionShape::paintDecorations(QPainter &painter, const KoViewConverter &converter, const KoCanvasBase *canvas)
{
Q_UNUSED(canvas);
if (!m_printable) {
applyConversion(painter, converter);
painter.setRenderHint(QPainter::Antialiasing);
draw(painter);
}
}
示例7: RenderMessage
void DBThread::RenderMessage(QPainter& painter, qreal width, qreal height, const char* message)
{
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::TextAntialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.fillRect(0,0,width,height,
QColor::fromRgbF(0.0,0.0,0.0,1.0));
painter.setPen(QColor::fromRgbF(1.0,1.0,1.0,1.0));
QString text(message);
painter.drawText(QRectF(0.0,0.0,width,height),
Qt::AlignCenter|Qt::AlignVCenter,
text,
NULL);
}
示例8:
void CMeter2DGraphView::InitializeRasterRenderer( QPainter& aPainter, QImage& anImage )
{
anImage.fill( 0x00000000 );
aPainter.begin( &anImage );
aPainter.setViewport( 0, 0, anImage.width(), anImage.height() );
aPainter.setWindow( 0, anImage.height(), anImage.width(), -anImage.height() );
aPainter.setRenderHint( QPainter::HighQualityAntialiasing );
}
示例9: paintEvent
void QRWidget::paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QPainter painter;
painter.begin(this);
painter.setRenderHint(QPainter::Antialiasing);
paint(painter);
painter.end();
}
示例10: paint
void paint(QPainter &painter){
painter.setRenderHint(QPainter::Antialiasing,true);
const T w=painter.device()->width();
const T h=painter.device()->height();
QPen base(QBrush(Qt::NoBrush),2);
QPen brown(base);
brown.setWidthF(0.01);
brown.setStyle(Qt::SolidLine);
brown.setColor(QColor("brown"));
QPen green(base);
green.setWidthF(0.04);
green.setColor(QColor("green"));
QPen purple(base);
purple.setWidthF(0.01);
purple.setColor(QColor("purple").darker());
painter.translate(w/2,h/2);
qreal s=qMin(w,h);
painter.scale(s,s);
T step=0.02;
T gx=cx/step;
gx-=floor(gx);
gx*=-step;
T gy=cy/step;
gy-=floor(gy);
gy*=-step;
painter.setPen(brown);
for(T y=gy-h;y<h;y+=step){
painter.drawLine(QPointF(0,y-1),QPointF(w,y+1));
}
for(T x=gx-w;x<w;x+=step){
painter.drawLine(QPointF(x-1,0),QPointF(x+1,h));
}
if(singleLimbMode){
limbs[0]->paint(painter);
}
else{
for(quint32 i=0;i<limbCount;++i){
limbs[i]->paint(painter);
}
const T r=0.01;
QPointF cob(cobx,coby);
painter.setPen(green);
painter.drawEllipse(cob,r,r);
QPointF cog(cogx,cogy);
painter.setPen(purple);
painter.drawEllipse(cog,r,r);
}
}
示例11: draw
void CodClassInstCanvas::draw(QPainter & p) {
if (visible()) {
p.setRenderHint(QPainter::Antialiasing, true);
ClassInstCanvas::draw(p, the_canvas(), rect());
if (selected())
show_mark(p, rect());
}
}
示例12: drawStartPos
/**
* @brief Draw the start position of the bot.
* @param painter
*/
void RenderArea::drawStartPos(QPainter &painter)
{
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::black);
painter.setBrush(QBrush(Qt::red));
painter.drawEllipse(this->x() + START_POS_X - BOT_RADIUS, this->y() + START_POS_Y - BOT_RADIUS, 2 * BOT_RADIUS, 2 * BOT_RADIUS);
painter.restore();
}
示例13: paint
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
{
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(dialColor);
p.setBrush(dialColor);
int dialStartAngle = 225 * 16;
int dialSpanAngle = -270 * 16;
// draw dial arc
p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
// draw ticks
p.save();
p.translate(dialRect.center());
p.rotate(45);
for (uint64_t i = 0; i < _div; i++) {
// draw major ticks
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
// draw minor ticks
for (uint64_t j = 0; (j < 5) && (i < _div - 1); j++) {
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
p.rotate(54.0/(_div-1));
}
}
// draw pointer
p.rotate(90+270.0/(_div-1)*_sel);
p.drawEllipse(-3, -3, 6, 6);
p.drawLine(3, 0, 0, dialRect.width()/2-3);
p.drawLine(-3, 0, 0, dialRect.width()/2-3);
p.restore();
// draw value
uint64_t displayValue = _value[_sel]*_factor;
uint64_t displayIndex = 0;
while(displayValue / _step >= 1) {
displayValue = displayValue / _step;
displayIndex++;
}
QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
QFontMetrics fm(p.font());
const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height());
p.drawText(valueRect, Qt::AlignCenter, pText);
// draw +/-
if (hover) {
const int arcInc = 15;
const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc, dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
const double arcSpan = hoverRect.width()/(2*sqrt(2));
p.drawArc(hoverRect, 135 * 16, -90 * 16);
if (inc)
p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
else
p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
}
}
示例14: 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());
}
示例15: paint_label
void Trace::paint_label(QPainter &p, int right, const QPoint pt)
{
compute_text_size(p);
const int y = get_y();
const QRectF color_rect = get_rect("color", y, right);
const QRectF name_rect = get_rect("name", y, right);
const QRectF label_rect = get_rect("label", get_zeroPos(), right);
p.setRenderHint(QPainter::Antialiasing);
// Paint the ColorButton
p.setPen(Qt::transparent);
p.setBrush(enabled() ? _colour : dsDisable);
p.drawRect(color_rect);
// Paint the signal name
p.setPen(enabled() ? Qt::black : dsDisable);
p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
// Paint the trigButton
paint_type_options(p, right, pt);
// Paint the label
if (enabled()) {
const QPointF points[] = {
label_rect.topLeft(),
label_rect.topRight(),
QPointF(right, get_zeroPos()),
label_rect.bottomRight(),
label_rect.bottomLeft()
};
p.setPen(Qt::transparent);
if (_type == SR_CHANNEL_DSO)
p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour);
else
p.setBrush((label_rect.contains(pt) || selected()) ? dsYellow : dsBlue);
p.drawPolygon(points, countof(points));
p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
p.setBrush(Qt::transparent);
p.drawLine(label_rect.right(), label_rect.top() + 3,
label_rect.right(), label_rect.bottom() - 3);
// Paint the text
p.setPen(Qt::white);
if (_type == SR_CHANNEL_GROUP)
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
else if (_type == SR_CHANNEL_ANALOG)
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
else if (_type == SR_CHANNEL_DECODER)
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
else
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
}
}