本文整理汇总了C++中QPainter::drawRoundedRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawRoundedRect方法的具体用法?C++ QPainter::drawRoundedRect怎么用?C++ QPainter::drawRoundedRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawRoundedRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_markers
void CursorPair::draw_markers(QPainter &p,
const QRect &rect, unsigned int prefix)
{
compute_text_size(p, prefix);
QRectF delta_rect(get_label_rect(rect));
const int radius = delta_rect.height() / 2;
const QRectF text_rect(delta_rect.intersected(
rect).adjusted(radius, 0, -radius, 0));
if(text_rect.width() >= _text_size.width())
{
const int highlight_radius = delta_rect.height() / 2 - 2;
p.setBrush(Cursor::FillColour);
p.setPen(Cursor::LineColour);
p.drawRoundedRect(delta_rect, radius, radius);
delta_rect.adjust(1, 1, -1, -1);
p.setPen(Cursor::HighlightColour);
p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius);
p.setPen(Cursor::TextColour);
p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
Ruler::format_time(_second.time() - _first.time(), prefix, 2));
}
// Paint the cursor markers
_first.paint_label(p, rect, prefix);
_second.paint_label(p, rect, prefix);
}
示例2: Render
void ZLamp::Render(QPainter &painter)
{
// Set Lamp color intensities
if (!lampLit) {
lampColor.setHsv(lampColor.hue(), lampColor.saturation(), lampColor.value()*0.2);
}
lampColorLow.setHsv(lampColor.hue(), lampColor.saturation(), lampColor.value()*0.8);
// Set Lamp gradients
lampGradient.setColorAt(0.0, lampColor);
lampGradient.setColorAt(1.0, lampColorLow);
// Draw everything
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(bezelGradient);
painter.drawRoundedRect(bezelRect, bezelWidth, bezelWidth);
painter.setPen(Qt::NoPen);
painter.setBrush(lampGradient);
painter.drawRoundedRect(lampRect, lampRadius, lampRadius);
painter.setPen(Qt::black);
painter.setFont(lampFont);
painter.drawText(lampRect, Qt::AlignCenter ,lampText);
}
示例3: paint
void TrackAnnotation::paint(QPainter &painter) {
// qDebug() << "TrackAnnotation::paint";
//qDebug() << "range.chromosome: " << range.chromosome;
if (!data.items.contains(range.chromosome)) return;
QList <AnnotationItem *> items;
//qDebug() << "nGene: " << data.items[range.chromosome].size();
for (int i = 0; i < data.items[range.chromosome].size(); i++) {
if (data.items[range.chromosome][i]->from > range.to) continue;
if (data.items[range.chromosome][i]->to < range.from) continue;
items.append(data.items[range.chromosome][i]);
}
painter.setPen(Qt::black);
painter.setFont(QFont("Arial", 9));
long w = range.to - range.from + 1;
double s = 1.0 * width / w;
for (int i = 0; i < items.size(); i++) {
long f = (items[i]->from - range.from) * s;
long t = (items[i]->to - range.from + 1) * s;
if (f < 0) f = 0;
if (t > width) t = width;
long yoff = items[i]->parent ? 20 : 0;
long h = 15;
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);
bool show_text = false;
if (items[i]->type == "gene") { painter.setPen(Qt::black); show_text = true; }
else if (items[i]->type == "repeat") { h = 6; painter.setBrush(Qt::blue); }
else if (items[i]->type == "cds") { yoff += 8; h = 6; painter.setBrush(Qt::red); }
// else if (items[i]->type == "exon") { h = 6; painter.setBrush(Qt::blue); }
else if (items[i]->type == "exon") { continue; }
else if (items[i]->type == "mrna") { continue; } // Don't draw
else { yoff += 8; painter.setBrush(Qt::yellow); show_text = true; } // Everything else goes there...
QRect r (label_offset + f, top + 2 + yoff, t-f, h);
items[i]->display = r;
painter.drawRoundedRect(r,5,5);
if (show_text) {
painter.setPen(Qt::black);
r.setTop(r.top()+2);
painter.drawText(r, Qt::AlignCenter, items[i]->name);
}
if (r.width() >= 20 && (items[i]->type=="repeat" || items[i]->type=="cds")) {
QString s = items[i]->strand == '+' ? QString::fromUtf8("→") : QString::fromUtf8("←");
painter.setPen(Qt::white);
painter.setFont(QFont("Arial", 11));
painter.drawText(r, Qt::AlignCenter, s);
painter.setFont(QFont("Arial", 9));
}
}
painter.setPen(Qt::lightGray);
painter.setBrush(Qt::NoBrush);
painter.drawRoundedRect(QRect(label_offset,top,width-1,height-1),5,5);
}
示例4: createLabel
void IndicatorLight::createLabel(int w, int h) {
if(_glowEnabled && this->scene()) {
// Draw label glow
QPixmap pixmap = QPixmap(w,h);
pixmap.fill(Qt::transparent);
QPainter painter;
painter.begin(&pixmap); {
setupPainter(&painter);
painter.setBrush(_labelColor);
painter.setPen(Qt::NoPen);
painter.drawRoundedRect(0,0,w,h,20,20);
} painter.end();
// Setup the graphics item for glow
// This has a special z-value ontop of other graphics items so that it can glow above the panel cover...
if(_labelGlowItem) {
this->scene()->removeItem(_labelGlowItem);
}
_labelGlowItem = new QGraphicsPixmapItem(NULL);
_labelGlowItem->setPixmap(pixmap);
_labelGlowItem->setOpacity(_glowStrength/100.0);
_labelGlowItem->setX(this->x());
_labelGlowItem->setY(this->y());
_labelGlowItem->setZValue(PANEL_PANELITEM_GLOW_ZVALUE);
QGraphicsBlurEffect *effect = new QGraphicsBlurEffect(this);
effect->setBlurRadius(40);
_labelGlowItem->setGraphicsEffect(effect);
this->scene()->addItem(_labelGlowItem);
}
}
示例5: drawLoadingMessage
void QUProfileController::drawLoadingMessage(QPainter & p)
{
if( avail() < m_total || m_total == 0)
{
p.save();
p.setFont ( m_captionFont);
p.setOpacity(1);
QString txt = QString( "Loading %1/%2").arg( avail()).arg(m_total);
QRectF anchor( m_buffer.width()/2.0, m_buffer.height()/2.0, 1, 1);
QRectF brect = p.boundingRect(
anchor, Qt::AlignCenter | Qt::TextDontClip,
txt);
brect.adjust( -3, -3, 3, 3);
QColor bg( 255, 255, 255, 225);
QColor border( 128, 0, 0, 225);
p.setPen( border);
p.setBrush( bg);
p.drawRoundedRect( brect, 5, 5);
p.setPen( QColor(0, 0, 0));
p.drawText(anchor, Qt::AlignCenter | Qt::TextDontClip,
txt);
p.setPen( QPen(QColor( 0, 0, 0, 128), 1, Qt::DashLine));
p.restore();
}
}
示例6: eventFilter
bool eventFilter(QObject *pO, QEvent *event)
{
if ( event->type() == QEvent::Paint) {
QWidget* pW = qobject_cast<QWidget*>(pO);
QColor backColor = NotificationServerSettings::instance()->value("notification_backgroundColor").value<QColor>();
float fOpacity = NotificationServerSettings::instance()->value("notification_opacity").value<float>();
QPainter painter ( pW );
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
// corners
const int kShadowCornerSize = scShadowSize + scRadiusSize;
painter.drawPixmap(0, 0, shadowsCorners.at(0));
painter.drawPixmap(pW->width() - kShadowCornerSize, 0, shadowsCorners.at(1));
painter.drawPixmap(pW->width() - kShadowCornerSize, pW->height() - kShadowCornerSize, shadowsCorners.at(2));
painter.drawPixmap(0, pW->height() - kShadowCornerSize, shadowsCorners.at(3));
//edges
painter.drawTiledPixmap(kShadowCornerSize, 0,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(0));
painter.drawTiledPixmap(pW->width() - scShadowSize, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(1));
painter.drawTiledPixmap(kShadowCornerSize, pW->height() - scShadowSize,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(2));
painter.drawTiledPixmap(0, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(3));
// rounded pixmap
painter.setBrush(backColor);
painter.setPen(backColor);
painter.setOpacity(fOpacity);
painter.drawRoundedRect(scShadowSize,scShadowSize,pW->width()-2*scShadowSize, pW->height()-2*scShadowSize,scRadiusSize,scRadiusSize);
}
}
示例7: fm
QPixmap LeechCraft::Util::DrawOverlayText (QPixmap px,
const QString& text, QFont font, const QPen& pen, const QBrush& brush)
{
const auto& iconSize = px.size ();
const auto fontHeight = px.height () * 0.45;
font.setPixelSize (std::max (6., fontHeight));
const QFontMetrics fm (font);
const auto width = fm.width (text) + 2. * px.width () / 10.;
const auto height = fm.height () + 2. * px.height () / 10.;
const bool tooSmall = width > iconSize.width ();
const QRect textRect (iconSize.width () - width, iconSize.height () - height, width, height);
QPainter p (&px);
p.setBrush (brush);
p.setFont (font);
p.setPen (pen);
p.setRenderHint (QPainter::Antialiasing);
p.setRenderHint (QPainter::TextAntialiasing);
p.setRenderHint (QPainter::HighQualityAntialiasing);
p.drawRoundedRect (textRect, 4, 4);
p.drawText (textRect,
Qt::AlignCenter,
tooSmall ? "#" : text);
p.end ();
return px;
}
示例8: drawRoundRect
void Services::drawRoundRect(QPainter& p, QRectF sizeRect, int borderSize, int borderRadius, QColor borderColor) {
QPen pen;
pen.setWidth(borderSize);
pen.setColor(borderColor);
pen.setJoinStyle(Qt::RoundJoin);
p.setPen(pen);
p.setBrush(Qt::NoBrush);
QRectF rect(sizeRect.x() - borderSize/2, sizeRect.y() - borderSize/2,
sizeRect.width() + borderSize, sizeRect.height() + borderSize);
if (borderSize % 2 == 0)
p.drawRoundedRect(rect, borderSize, borderSize);
else
p.drawRoundedRect(rect.translated(0.5, 0.5), borderRadius, borderRadius);
}
示例9: addContactEntry
void ContactListEdit::addContactEntry(const QString& contactText, const bts::addressbook::contact& c)
{
QFont default_font;
default_font.setPointSize( default_font.pointSize() - 1 );
QFontMetrics font_metrics(default_font);
QRect bounding = font_metrics.boundingRect(contactText);
int completion_width = font_metrics.width(contactText);
int completion_height = bounding.height();
completion_width += 20;
QImage completion_image(completion_width, completion_height + 4, QImage::Format_ARGB32);
completion_image.fill(QColor(0, 0, 0, 0) );
QPainter painter;
painter.begin(&completion_image);
painter.setFont(default_font);
painter.setRenderHint(QPainter::Antialiasing);
QBrush brush(Qt::SolidPattern);
brush.setColor( QColor( 205, 220, 241 ) );
QPen pen;
bool isKeyhoteeFounder = Contact::isKeyhoteeFounder(c);
if (isKeyhoteeFounder)
{
QLinearGradient grad(QPointF(0, 0), QPointF(0, 1));
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
grad.setColorAt(0.3, QColor(231, 190, 66));
grad.setColorAt(1.0, QColor(103, 51, 1));
brush = QBrush(grad);
pen.setColor( QColor( 103, 51, 1 ) );
}
else
{
brush.setColor( QColor( 205, 220, 241 ) );
pen.setColor( QColor( 105,110,180 ) );
}
painter.setBrush(brush);
painter.setPen(pen);
painter.drawRoundedRect(0, 0, completion_width - 1, completion_image.height() - 1, 8, 8,
Qt::AbsoluteSize);
painter.setPen(QPen());
painter.drawText(QPoint(10, completion_height - 2), contactText);
QTextCursor text_cursor = textCursor();
uint32_t prefix_len = _completer->completionPrefix().length();
for (uint32_t i = 0; i < prefix_len; ++i)
text_cursor.deletePreviousChar();
// int extra = completion.length() -
// tc.movePosition(QTextCursor::Left);
// tc.movePosition(QTextCursor::EndOfWord);
// tc.insertText(completion.right(extra));
text_cursor.insertImage(completion_image, contactText);
text_cursor.insertText(" ");
setTextCursor(text_cursor);
}
示例10: drawTransRect
void Scene::drawTransRect(QPainter& painter, const QRect& rectangle, QColor borderColor,
QColor backgroundColor, qreal opacity) {
painter.setOpacity(opacity);
painter.setPen(QPen(borderColor, 2));
painter.setBrush(backgroundColor);
int radius = 5;
painter.drawRoundedRect(rectangle, radius, radius);
}
示例11: pen
void
DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity )
{
p.setBackgroundMode( Qt::TransparentMode );
p.setRenderHint( QPainter::Antialiasing );
p.setOpacity( opacity );
QPen pen( pal.dark().color(), .5 );
p.setPen( pen );
p.setBrush( pal.highlight() );
p.drawRoundedRect( r, 10, 10 );
p.setOpacity( opacity + .2 );
p.setBrush( QBrush() );
p.setPen( pen );
p.drawRoundedRect( r, 10, 10 );
}
示例12: redrawBorders
void MainWindow::redrawBorders()
{
QBitmap objBitmap(size());
QPainter painter;
QRect rect(position(), QPoint(position().x() + width(), position().y() + height()));
painter.fillRect(rect,Qt::white);
painter.setBrush(QColor(0,0,0));
painter.drawRoundedRect(rect,10,10);
setMask(objBitmap);
}
示例13: paintEvent
void GuiBadgeIcon::paintEvent(QPaintEvent *)
{
QRectF rectangle(18, 10, height, height);
QPainter paint;
paint.begin(this);
paint.setPen(color);
paint.setBrush(QBrush(color, Qt::SolidPattern));
paint.setRenderHint(QPainter::Antialiasing,true);
paint.drawRoundedRect(rectangle, 7, 7);
paint.end();
}
示例14: drawTransRect
void IScene::drawTransRect(QPainter &p, const QRect &r, QColor borderColor, QColor bgColor, qreal op)
{
p.setOpacity(op);
p.setPen(QPen(borderColor, 2));
p.setBrush(bgColor);
#if QT_VERSION >= 0x040400
p.drawRoundedRect(r, 5,5);
#else
p.drawRect(r);
#endif
}
示例15: paintEvent
void GuiCombWidget::paintEvent(QPaintEvent *)
{
QRectF rectangle(0, 0, this->width(), this->height());
QPainter paint;
paint.begin(this);
paint.setPen(QPen(Qt::NoPen));
paint.setBrush(QBrush(window_color,Qt::SolidPattern));
paint.drawRoundedRect(rectangle,5,5);
paint.end();
}