本文整理汇总了C++中QPainter::drawRoundRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawRoundRect方法的具体用法?C++ QPainter::drawRoundRect怎么用?C++ QPainter::drawRoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawRoundRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void counter::paint(QPainter &p, bool drawScore, int score, bool drawTimer, const QColor &c1, const QColor &c2, const QColor &c3, QSvgRenderer *renderer)
{
p.save();
p.translate(45, 15);
p.setPen(QPen(Qt::black, 3));
p.setBrush(QColor(40, 40, 40));
if (drawTimer)
{
p.fillRect(-44, -13, 98, 48, p.brush());
p.drawRoundRect(-45, -15, 100, 50, 15, 15);
}
else
{
p.fillRect(-44, -13, 70, 48, p.brush());
p.drawRoundRect(-45, -15, 73, 50, 15, 15);
}
if (drawTimer)
{
p.fillRect(35, -6, 11, 9, c1);
p.fillRect(35, 6, 11, 9, c2);
p.fillRect(35, 18, 11, 9, c3);
}
if (drawScore)
{
p.translate(-5, -5);
number n(score);
n.paint(p, 2, renderer);
}
p.restore();
}
示例2: drawShape
void CanvasRoundRect::drawShape(QPainter &p)
{
if ( qt_screen->deviceWidth() < 200 )
p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
else
p.drawRoundRect( (int)x(), (int)y(), 23, 36);
}
示例3: drawFoldingLineHidden
void WTextSourceViewerLine::drawFoldingLineHidden(QPainter &p,const QPointF &pt)
{
float demi_char_space=char_space/2.0f;
QPointF pos(0,pt.y()-demi_char_space);
QRectF text_pos(pos,QSizeF(char_space,char_space));
QPointF p3(pt.x(),pt.y());
QPointF p1c(char_space,pt.y());
QBrush b=p.brush();
p.setBrush(Qt::black);
QRectF endPoint3(p3.x()-2,p3.y()-2,4,4);
p.drawEllipse(endPoint3);
p.setBrush(b);
p.drawLine(p1c,p3);
float pos_size=char_space;
QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
p.drawRoundRect(rectangle);
float _x1=pos.x()+3.0f;
float _y=pos.y()+pos_size/2.0f;
float _x2=pos.x()+pos_size-3.0f;
float _x=pos.x()+pos_size/2;
float _y1=pos.y()+3;
float _y2=pos.y()+pos_size-3;
p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
p.drawLine(QPointF(_x,_y1),QPointF(_x,_y2));
}
示例4: drawShape
void PicItem::drawShape( QPainter & p )
{
int _x = int(x());
int _y = int(y());
p.setBrush( QColor( 0xef, 0xff, 0xef ) );
p.setFont( font() );
p.drawRoundRect( _x, _y, width(), height(), 2000/width(), 2000/height() );
p.drawText( _x+TopPadding-2, _y, width()-TopPadding+2, TopPadding, Qt::AlignVCenter, i18n("PIC Settings") );
if ( !m_bExpanded )
return;
// Draw rectangle to cut off pins
p.setBrush( QColor( 239, 255, 255 ) );
QRect r( _x+SidePadding, _y+TopPadding, InnerWidth, m_innerHeight );
p.drawRect(r);
// Draw dimple thingy at end of pic
p.drawArc( r.x()+(r.width()-ArcWidth)/2, r.y()+1-ArcWidth/2, ArcWidth, ArcWidth, 180*16, 180*16 );
// Draw vertical text centered in PIC
p.translate( r.width()/2 + r.x(), r.height()/2 + r.y() );
p.rotate(90);
QRect textRect( r.width()/-2, r.height()/-2, r.width(), r.height() );
p.drawText( textRect, Qt::AlignCenter, microSettings->microInfo()->id() );
p.rotate(-90);
p.translate( r.width()/-2 - r.x(), r.height()/-2 - r.y() );
}
示例5: RoundedRectangle
void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore,
ColourDesired back)
{
Q_ASSERT(painter);
painter->setPen(convertQColor(fore));
painter->setBrush(convertQColor(back));
painter->drawRoundRect(
QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
}
示例6: drawForeground
void Canvas::drawForeground(QPainter &p, const QRect & clip) {
QCanvas::drawForeground(p, clip);
if (!m_pMessageTimeout->isActive())
return;
// Following code stolen and adapted from amarok/src/playlist.cpp :)
// Find out width of smallest view
QSize minSize;
const ViewList viewList = p_itemDocument->viewList();
ViewList::const_iterator end = viewList.end();
View *firstView = 0;
for (ViewList::const_iterator it = viewList.begin(); it != end; ++it) {
if (!*it) continue;
if (!firstView) {
firstView = *it;
minSize = (*it)->size();
} else minSize = minSize.boundedTo((*it)->size());
}
if (!firstView) return;
QSimpleRichText *t = new QSimpleRichText(m_message, QApplication::font());
const int w = t->width();
const int h = t->height();
const int x = rect().left() + 15;
const int y = rect().top() + 15;
const int b = 10; // text padding
if (w + 2 * b >= minSize.width() || h + 2 * b >= minSize.height()) {
delete t;
return;
}
p.setBrush(firstView->colorGroup().background());
p.drawRoundRect(x, y,
w + 2 * b,
h + 2 * b,
(8 * 200) / (w + 2 * b),
(8 * 200) / (h + 2 * b));
t->draw(&p, x + b, y + b, QRect(), firstView->colorGroup());
delete t;
}
示例7: pinRect
//!
//! Constructor of the ParameterTypeIcon class.
//!
//! \param color The color for the parameter type icon.
//!
ParameterTypeIcon::ParameterTypeIcon ( const QColor &color )
{
m_color = color;
const QRect pinRect (0, 4, 15, 8);
const QColor penColor (109, 109, 109);
QPixmap normalPixmap (16, 16);
QPainter painter;
if (painter.begin(&normalPixmap)) {
// get the background color from the application style's standard palette
QColor backgroundColor = QApplication::style()->standardPalette().color(QPalette::Base);
// fill the pixmap with the background color
painter.fillRect(normalPixmap.rect(), QBrush(backgroundColor));
// draw the pin rect into the pixmap
painter.setPen(QPen(penColor));
painter.setBrush(QBrush(m_color));
painter.drawRoundRect(pinRect);
// end painting the pixmap
if (painter.end()) {
// create a bitmap for masking the pixmap
QBitmap maskBitmap (normalPixmap.size());
if (painter.begin(&maskBitmap)) {
// fill the bitmap with white (meaning transparent)
painter.fillRect(maskBitmap.rect(), QBrush(QColor(Qt::white)));
// draw the pin rect as black (meaning opaque)
painter.setPen(QPen(QColor(Qt::black)));
painter.setBrush(QBrush(QColor(Qt::black)));
painter.drawRoundRect(pinRect);
// end painting the bitmap and set it as mask for the pixmap
if (painter.end())
normalPixmap.setMask(maskBitmap);
}
}
}
// add the pixmap to the icon
addPixmap(normalPixmap);
}
示例8: drawShape
void FlowContainer::drawShape( QPainter &p )
{
if (b_deleted)
return;
if ( !m_sizeRect.isValid() )
return;
const int _x = (int)x()+offsetX();
const int _y = (int)y()+offsetY();
int col = 0xef + level()*0x6;
if ( col > 0xff ) col = 0xff;
p.setBrush( QColor( col, 0xff, col ) );
if( b_expanded )
{
p.setPen(Qt::DotLine);
p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
p.drawRoundRect( _x, _y+height()-botStrip, width(), botStrip, 1500/width(), 1500/botStrip );
}
else
{
p.setPen(QPen((isSelected()?m_selectedCol:Qt::black),1,Qt::SolidLine));
p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
}
p.setPen( Qt::black );
p.setFont( font() );
p.drawText( QRect( 22 + _x+8, _y, width()-8, topStrip ), Qt::AlignLeft | Qt::AlignVCenter, m_caption );
if( b_expanded )
{
p.setPen(Qt::SolidLine);
p.setBrush( Qt::NoBrush );
p.drawRoundRect( _x, _y, width(), height(), 1500/width(), 1500/height() );
}
}
示例9: paint
void RegionWidget::paint(QPainter & p, int offsetX, int offsetY)
{
setPenFromSettings(p);
const int w = width();
const int h = height();
QPen pen = p.pen();
{
setPenFromSettings(p);
pen.setColor ( Qt::red );
pen.setStyle ( Qt::DashLine );
p.setPen( pen );
p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
}
if(m_selected)
drawSelected(&p, offsetX, offsetY);
}
示例10: dibujarNodo
void RenderArea::dibujarNodo(Nodo n,QPainter &P)
{
QColor color(Qt::blue);
QFontMetrics m(QFont("prueba",11,2,true));
int x = m.boundingRect(n.etiqueta).width();
int y = m.boundingRect(n.etiqueta).height();
P.setPen(Qt::black);
if(n.pintado)
P.setBrush(color);
else
P.setBrush(Qt::white);
P.drawRoundRect(n.x,n.y,x,y);
P.drawText(n.x+15,n.y+15,n.etiqueta);
}
示例11: drawFoldingLineVisible
void WTextSourceViewerLine::drawFoldingLineVisible(QPainter &p,const QPointF &p1,const QPointF &p2)
{
QPolygonF area;
float demi_char_space=char_space/2.0f;
QPointF pos(0.0f,(p1.y()+p2.y())/2.0f-demi_char_space);
QRectF text_pos(pos,QSizeF(char_space,char_space));
QPointF p3(demi_char_space,p2.y());
QRectF endPoint2(p2.x()-2,p2.y()-2,4,4);
QBrush b=p.brush();
p.setBrush(Qt::black);
if (p1!=p2)
{
QPointF p0(demi_char_space,p1.y());
QPointF p1b(demi_char_space,pos.y());
QPointF p2b(demi_char_space,pos.y()+char_space);
QRectF endPoint1(p1.x()-2,p1.y()-2,4,4);
area << p0 << p1 ;
area << p0 << p1b ;
area << p2b << p3 ;
area << p3 << p2 ;
p.drawEllipse(endPoint1);
}
else
{
QPointF p1c(char_space,p2.y());
area << p1c << p2 ;
}
p.drawEllipse(endPoint2);
p.setBrush(b);
p.drawLines(area);
float pos_size=char_space;
QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
p.drawRoundRect(rectangle);
float _x1=pos.x()+3.0f;
float _y=pos.y()+pos_size/2.0f;
float _x2=pos.x()+pos_size-3.0f;
p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
}
示例12: drawShape
void GearGui_ListBox::drawShape(QPainter &painter)
{
//make the title bar show the value
std::ostringstream sstream;
std::string str = ((Gear_ListBox*)_gear)->getLabel();
sstream << str;//((Gear_ListBox*)_gear)->getLabel();
setTitle(sstream.str());
GearGui::drawShape(painter);
int sliderStartX, sliderStartY, sizeX, sizeY;
getDrawableArea(&sliderStartX, &sliderStartY, &sizeX , &sizeY);
//convert sliderpos to screen value
int hi = _gear->settings().get(Gear_ListBox::SETTING_NELEMS)->valueInt()-1;
float screenRatio;
if (hi == 0)
screenRatio = 0.5f;
else
screenRatio = ((Gear_ListBox*)_gear)->getValue() / (float)hi;
int sliderPos = (int) ((float)(screenRatio * (float)(sizeX-SLIDER_THICKNESS)));
//box
painter.setPen(Qt::black);
painter.setBrush(SLIDER_BOX_COLOR);
painter.drawRect(sliderStartX, sliderStartY, sizeX, sizeY);
painter.drawRect(sliderStartX, sliderStartY + SLIDER_LINE_OFFSETY, sizeX, 1);
//3d
painter.setPen(Qt::white);
painter.drawRect(sliderStartX, sliderStartY + sizeY - 1, sizeX, 1);
painter.drawRect(sliderStartX + sizeX - 1, sliderStartY, 1, sizeY);
//slider
painter.setPen(Qt::black);
painter.setBrush(SLIDER_COLOR);
painter.drawRoundRect(sliderStartX + sliderPos, sliderStartY, SLIDER_THICKNESS, sizeY, 85);
}
示例13: resizeEvent
void Board::resizeEvent(QResizeEvent* event)
{
m_piece_size = qMin(event->size().width() / 10, event->size().height() / 20);
int w = m_piece_size * 10 + 1;
int h = m_piece_size * 20 + 1;
m_background = QRect((width() - w) / 2, (height() - h) / 2, w, h);
QPainter painter;
for (int i = 0; i < 7; ++i) {
QPixmap pixmap(m_piece_size + 1, m_piece_size + 1);
pixmap.fill(QColor(0, 0, 0, 0));
painter.begin(&pixmap);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setBrush(colors[i]);
painter.setPen(QPen(colors[i].lighter(), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.drawRoundRect(1, 1, m_piece_size - 1, m_piece_size - 1);
painter.end();
m_images[i] = pixmap;
}
}
示例14: AlphaRectangle
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize,
ColourDesired fill, int alphaFill, ColourDesired outline,
int alphaOutline, int)
{
Q_ASSERT(painter);
QColor outline_colour = convertQColor(outline, alphaOutline);
QColor fill_colour = convertQColor(fill, alphaFill);
// There was a report of Qt seeming to ignore the alpha value of the pen so
// so we disable the pen if the outline and fill colours are the same.
if (outline_colour == fill_colour)
painter->setPen(Qt::NoPen);
else
painter->setPen(outline_colour);
painter->setBrush(fill_colour);
const int radius = (cornerSize ? 25 : 0);
painter->drawRoundRect(
QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top),
radius, radius);
}
示例15: drawShape
void FlowPart::drawShape(QPainter &p) {
initPainter(p);
const double _x = int(x() + offsetX());
const double _y = int(y() + offsetY());
const double w = width();
double h = height();
switch (m_flowSymbol) {
case FlowPart::ps_other:
CNItem::drawShape(p);
break;
case FlowPart::ps_io: {
h--;
double roundSize = 8;
double slantIndent = 5;
// CNItem::drawShape(p);
double inner = std::atan(h / slantIndent);
double outer = M_PI - inner;
int inner16 = int(16 * inner * DPR);
int outer16 = int(16 * outer * DPR);
p.save();
p.setPen(Qt::NoPen);
p.drawPolygon(areaPoints());
p.restore();
p.drawLine(int(_x + slantIndent + roundSize / 2),
int(_y),
int(_x + w - roundSize / 2),
int(_y));
p.drawLine(int(_x + w - slantIndent - roundSize / 2),
int(_y + h),
int(_x + roundSize / 2),
int(_y + h));
p.drawLine(int(_x + w + (std::sin(outer) - 1) * roundSize / 2),
int(_y + (1 - std::cos(outer)) * roundSize / 2),
int(_x + w - slantIndent + (std::sin(inner) - 1) * roundSize / 2),
int(_y + h + (std::cos(inner) - 1) * roundSize / 2));
p.drawLine(int(_x + (1 - std::sin(outer)) * roundSize / 2),
int(_y + h + (std::cos(outer) - 1) * roundSize / 2),
int(_x + slantIndent + (1 - std::sin(inner)) * roundSize / 2),
int(_y + (1 - std::cos(inner)) * roundSize / 2));
p.drawArc(int(_x + slantIndent),
int(_y),
int(roundSize),
int(roundSize),
90 * 16,
inner16);
p.drawArc(int(_x + w - roundSize),
int(_y),
int(roundSize),
int(roundSize),
270 * 16 + inner16,
outer16);
p.drawArc(int(_x - slantIndent + w - roundSize),
int(_y + h - roundSize),
int(roundSize),
int(roundSize),
270*16,
inner16);
p.drawArc(int(_x),
int(_y + h - roundSize),
int(roundSize),
int(roundSize),
90*16 + inner16,
outer16);
break;
}
case FlowPart::ps_decision:
// TODO Make the shape nice and pretty with rounded corners
CNItem::drawShape(p);
break;
case FlowPart::ps_call:
p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
p.drawLine(int(_x + 8), int(_y), int(_x + 8), int(_y + h));
p.drawLine(int(_x + w - 8), int(_y), int(_x + w - 8), int(_y + h));
break;
case FlowPart::ps_process:
p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
break;
case FlowPart::ps_round:
p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), 30, 100);
break;
}
//.........这里部分代码省略.........