本文整理汇总了C++中QPainter::drawTiledPixmap方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawTiledPixmap方法的具体用法?C++ QPainter::drawTiledPixmap怎么用?C++ QPainter::drawTiledPixmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawTiledPixmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: updateActiveBuffer
void LaptopClient::updateActiveBuffer( )
{
QRect rTitle = titleRect();
if( !bufferDirty && (lastBufferWidth == rTitle.width()))
return;
if ( rTitle.width() <= 0 || rTitle.height() <= 0 )
return;
lastBufferWidth = rTitle.width();
bufferDirty = false;
activeBuffer = QPixmap(rTitle.width(), rTitle.height());
QPainter p;
QRect r(0, 0, activeBuffer.width(), activeBuffer.height());
p.begin(&activeBuffer);
if(aUpperGradient){
p.drawTiledPixmap(r, *aUpperGradient);
}
else{
p.fillRect(r, options()->color(KDecoration::ColorTitleBar, true));
}
if(titlePix)
p.drawTiledPixmap(r, *titlePix);
p.setFont(options()->font(true, isToolWindow() ));
QFontMetrics fm(options()->font(true));
QPalette g = options()->palette(KDecoration::ColorTitleBar, true);
g.setCurrentColorGroup( QPalette::Active );
if(aUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
*aUpperGradient);
else
p.fillRect(r.x()+((r.width()-fm.width(caption()))/2)-4, 0,
fm.width(caption())+8, r.height(),
g.brush(QPalette::Background));
p.setPen(g.mid().color());
p.drawLine(r.x(), r.y(), r.right(), r.y());
p.drawLine(r.x(), r.y(), r.x(), r.bottom());
p.setPen(g.color(QPalette::Button));
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options()->color(KDecoration::ColorFont, true));
p.drawText(r.x(), r.y()+1, r.width(), r.height()-1,
Qt::AlignCenter, caption() );
g = options()->palette(KDecoration::ColorFrame, true);
g.setCurrentColorGroup( QPalette::Active );
p.setPen(g.background().color());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
p.drawLine(r.right()+1, r.y(), r.right()+1, r.bottom());
p.end();
}
示例3: paintEvent
void KviThemedLabel::paintEvent(QPaintEvent *e)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
QPainter *p = new QPainter(this);
#if (QT_VERSION >= 0x050000)
// In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what.
qDrawShadePanel(p,0,0,width(),height(),palette(),true,1,NULL);
QRect r(1,1,width()-1,height()-1);
#else
QStyleOptionFrameV2 option;
option.initFrom(this);
style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, p, this);
QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &option, this);
#endif
if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
{
p->setCompositionMode(QPainter::CompositionMode_Source);
QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
p->fillRect(r, col);
} else if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft());
p->drawTiledPixmap(r,*(g_pShadedChildGlobalDesktopBackground), pnt);
}
delete p;
#endif
QLabel::paintEvent(e);
}
示例4: paintEvent
void paintEvent(QPaintEvent *event)
{
QPainter *p = new QPainter(this);
p->drawTiledPixmap(0, 0, width(), height(), *pixmap());
delete p;
QLabel::paintEvent(event);
}
示例5: paintEvent
void KviThemedLineEdit::paintEvent(QPaintEvent * event)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
QPainter * p = new QPainter(this);
QPalette pal = palette();
// In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what.
qDrawShadePanel(p, 0, 0, width(), height(), palette(), true, 1, nullptr);
QRect r(1, 1, width() - 2, height() - 2);
if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
{
p->setCompositionMode(QPainter::CompositionMode_Source);
QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
p->fillRect(r, col);
p->restore();
}
else if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt;
if(m_pKviWindow)
pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft());
else
pnt = mapToGlobal(event->rect().topLeft());
p->drawTiledPixmap(r, *(g_pShadedChildGlobalDesktopBackground), pnt);
}
delete p;
#endif
QLineEdit::paintEvent(event);
}
示例6: paintEvent
void UrlDialogTreeWidget::paintEvent(QPaintEvent * event)
{
QPainter * p = new QPainter(viewport());
QStyleOptionViewItem option = viewOptions();
QRect rect = event->rect();
#ifdef COMPILE_PSEUDO_TRANSPARENCY
if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
{
p->save();
p->setCompositionMode(QPainter::CompositionMode_Source);
QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
p->fillRect(rect, col);
p->restore();
}
else if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt = ((KviWindow *)parent())->isDocked() ? viewport()->mapTo(g_pMainWindow, rect.topLeft()) : viewport()->mapTo((KviWindow *)parent(), rect.topLeft());
p->drawTiledPixmap(rect, *(g_pShadedChildGlobalDesktopBackground), pnt);
}
else
{
#endif
//FIXME this is not the treewindowlist
p->fillRect(rect, KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground));
#ifdef COMPILE_PSEUDO_TRANSPARENCY
}
#endif
delete p;
//call paint on all children
QTreeWidget::paintEvent(event);
}
示例7: draw
void TouchUI::draw( QPainter & painter )
{
_screen_width = painter.window().width();
_screen_height = painter.window().height();
limitScroll();
// draw background
QRect rect(0,0,painter.window().width(),_height);
painter.drawTiledPixmap( rect, _background );
// draw icons
for ( int i = 0; i < _items.count(); i++ )
{
UIItem * t = _items[i];
int posx = t->x1;
int posy = t->y1;
if ( posx < 0 ) posx = _screen_width+posx;
QSvgRenderer * image = t->image;
if ( t->highlighted )
painter.setCompositionMode( QPainter::CompositionMode_HardLight );
else
painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
if ( image == NULL ) continue;
int h = image->defaultSize().height();
int w = image->defaultSize().width();
int img_width = g_config.ui_size;
int img_height = g_config.ui_size;
ImageLoadThread::fitImage( w,h, img_width, img_height, false );
QRectF r( posx+_xoffset, posy+_yoffset, w, h );
image->render( &painter, r );
}
}
示例8: drawPattern
void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
{
QPixmap* framePixmap = nativeImageForCurrentFrame();
if (!framePixmap) // If it's too early we won't have an image yet.
return;
QPixmap pixmap = *framePixmap;
QRect tr = QRectF(tileRect).toRect();
if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) {
pixmap = pixmap.copy(tr);
}
if (patternTransform.isIdentity()) {
ctxt->save();
ctxt->setCompositeOperation(op);
QPainter* p = ctxt->platformContext();
p->setBrushOrigin(phase);
p->drawTiledPixmap(destRect, pixmap);
ctxt->restore();
} else {
QBrush b(pixmap);
b.setMatrix(patternTransform);
ctxt->save();
ctxt->setCompositeOperation(op);
QPainter* p = ctxt->platformContext();
p->setBrushOrigin(phase);
p->fillRect(destRect, b);
ctxt->restore();
}
}
示例9: draw
bool ColorSchemeWallpaper::draw(QPainter& painter, const QRect& rect)
{
if (!_picture || _picture->isNull())
return false;
painter.drawTiledPixmap(rect, *_picture, rect.topLeft());
return true;
}
示例10: c
const QPixmap &PlastikClient::captionPixmap() const
{
bool active = isActive();
if(m_captionPixmaps[active])
{
return *m_captionPixmaps[active];
}
// not found, create new pixmap...
const uint maxCaptionLength = 300; // truncate captions longer than this!
QString c(caption());
if(c.length() > maxCaptionLength)
{
c.truncate(maxCaptionLength);
c.append(" [...]");
}
QFontMetrics fm(s_titleFont);
int captionWidth = fm.width(c);
int captionHeight = fm.height();
const int th = layoutMetric(LM_TitleHeight, false) + layoutMetric(LM_TitleEdgeBottom, false);
QPainter painter;
const int thickness = 2;
QPixmap *captionPixmap = new QPixmap(captionWidth + 2 * thickness, th);
painter.begin(captionPixmap);
painter.drawTiledPixmap(captionPixmap->rect(), Handler()->pixmap(TitleBarTile, active, isToolWindow()));
painter.setFont(s_titleFont);
QPoint tp(1, captionHeight - 1);
if(Handler()->titleShadow())
{
QColor shadowColor;
if(qGray(Handler()->getColor(TitleFont, active).rgb()) < 100)
shadowColor = QColor(255, 255, 255);
else
shadowColor = QColor(0, 0, 0);
painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 205));
painter.drawText(tp + QPoint(1, 2), c);
painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 225));
painter.drawText(tp + QPoint(2, 2), c);
painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 165));
painter.drawText(tp + QPoint(1, 1), c);
}
painter.setPen(Handler()->getColor(TitleFont, active));
painter.drawText(tp, c);
painter.end();
m_captionPixmaps[active] = captionPixmap;
return *captionPixmap;
}
示例11: c
const QPixmap &PlastikClient::captionPixmap() const
{
bool active = isActive();
if (m_captionPixmaps[active]) {
return *m_captionPixmaps[active];
}
// not found, create new pixmap...
const int maxCaptionLength = 300; // truncate captions longer than this!
QString c(caption() );
if (c.length() > maxCaptionLength) {
c.truncate(maxCaptionLength);
c.append(" [...]");
}
QFontMetrics fm(s_titleFont);
int captionWidth = fm.width(c);
int captionDescent = fm.descent();
QFontMetrics fm_vmname(s_vmnameFont);
captionWidth += fm_vmname.width(qubes_vmname);
if (fm_vmname.descent() > fm.descent()) captionDescent = fm_vmname.descent();
const int th = layoutMetric(LM_TitleHeight, false) + layoutMetric(LM_TitleEdgeBottom, false);
QPainter painter;
const int thickness = 2;
QPixmap *captionPixmap = new QPixmap(captionWidth+2*thickness, th);
painter.begin(captionPixmap);
painter.drawTiledPixmap(captionPixmap->rect(),
Handler()->pixmap(qubes_label, TitleBarTile, active, isToolWindow()) );
painter.setFont(s_vmnameFont);
QRect boundingRect1 = painter.boundingRect(captionPixmap->rect(),
Qt::AlignVCenter | Qt::AlignLeft, qubes_vmname);
QPoint tp1 = boundingRect1.bottomLeft() - QPoint(0, captionDescent);
QPoint tp2 = tp1 + QPoint (fm_vmname.width(qubes_vmname) + 5, 0);
QColor fontColor = Handler()->getColor(qubes_label, TitleFont,active);
painter.setPen(fontColor );
painter.drawText(tp1, qubes_vmname );
painter.setFont(s_titleFont);
painter.drawText(tp2, c );
painter.end();
m_captionPixmaps[active] = captionPixmap;
return *captionPixmap;
}
示例12: paint
void KoPatternBackground::paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &/*context*/, const QPainterPath &fillPath) const
{
Q_D(const KoPatternBackground);
if (! d->imageData)
return;
painter.save();
if (d->repeat == Tiled) {
// calculate scaling of pixmap
QSizeF targetSize = d->targetSize();
QSizeF imageSize = d->imageData->imageSize();
qreal scaleX = targetSize.width() / imageSize.width();
qreal scaleY = targetSize.height() / imageSize.height();
QRectF targetRect = fillPath.boundingRect();
// undo scaling on target rectangle
targetRect.setWidth(targetRect.width() / scaleX);
targetRect.setHeight(targetRect.height() / scaleY);
// determine pattern offset
QPointF offset = d->offsetFromRect(targetRect, imageSize);
// create matrix for pixmap scaling
QTransform matrix;
matrix.scale(scaleX, scaleY);
painter.setClipPath(fillPath);
painter.setWorldTransform(matrix, true);
painter.drawTiledPixmap(targetRect, d->imageData->pixmap(imageSize.toSize()), -offset);
} else if (d->repeat == Original) {
QRectF sourceRect(QPointF(0, 0), d->imageData->imageSize());
QRectF targetRect(QPoint(0, 0), d->targetSize());
targetRect.moveCenter(fillPath.boundingRect().center());
painter.setClipPath(fillPath);
painter.drawPixmap(targetRect, d->imageData->pixmap(sourceRect.size().toSize()), sourceRect);
} else if (d->repeat == Stretched) {
painter.setClipPath(fillPath);
// undo conversion of the scaling so that we can use a nicely scaled image of the correct size
qreal zoomX, zoomY;
converter.zoom(&zoomX, &zoomY);
zoomX = zoomX ? 1 / zoomX : zoomX;
zoomY = zoomY ? 1 / zoomY : zoomY;
painter.scale(zoomX, zoomY);
QRectF targetRect = converter.documentToView(fillPath.boundingRect());
painter.drawPixmap(targetRect.topLeft(), d->imageData->pixmap(targetRect.size().toSize()));
}
painter.restore();
}
示例13: paintEvent
void KviThemedComboBox::paintEvent(QPaintEvent * event)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
QPainter * p = new QPainter(this);
QLineEdit * le = lineEdit();
if(le)
{
QRect r = rect();
QPalette pal = palette();
QStyleOptionFrame option;
option.initFrom(this);
option.rect = contentsRect();
option.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, le);
option.midLineWidth = 0;
option.state |= QStyle::State_Sunken;
if(le->isReadOnly())
option.state |= QStyle::State_ReadOnly;
option.features = QStyleOptionFrame::None;
style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, p, this);
r = style()->subElementRect(QStyle::SE_LineEditContents, &option, le);
int left, right, top, bottom;
le->getTextMargins(&left, &top, &right, &bottom);
r.setX(r.x() + left);
r.setY(r.y() + top);
r.setRight(r.right() - right);
r.setBottom(r.bottom() - bottom);
p->setClipRect(r);
} // else not editable
if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
{
p->setCompositionMode(QPainter::CompositionMode_Source);
QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
p->fillRect(contentsRect(), col);
}
else if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, contentsRect().topLeft()) : mapTo(m_pKviWindow, contentsRect().topLeft());
p->drawTiledPixmap(contentsRect(), *(g_pShadedChildGlobalDesktopBackground), pnt);
}
delete p;
#endif
QComboBox::paintEvent(event);
}
示例14: fill
void QPixmap::fill( const QWidget *widget, int xofs, int yofs )
{
const QPixmap* bgpm = widget->backgroundPixmap();
fill( widget->backgroundColor() );
if ( bgpm ) {
if ( !bgpm->isNull() ) {
QPoint ofs = widget->backgroundOffset();
xofs += ofs.x();
yofs += ofs.y();
QPainter p;
p.begin( this );
p.setPen( NoPen );
p.drawTiledPixmap( 0, 0, width(), height(), *widget->backgroundPixmap(), xofs, yofs );
p.end();
}
}
}
示例15: paintEvent
void KviThemedTreeWidget::paintEvent(QPaintEvent *e)
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
QPainter *p = new QPainter(this->viewport());
if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
{
p->setCompositionMode(QPainter::CompositionMode_Source);
QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade);
col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100));
p->fillRect(viewport()->contentsRect(), col);
} else if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt = m_pKviWindow->isDocked() ? viewport()->mapTo(g_pMainWindow, contentsRect().topLeft() + viewport()->contentsRect().topLeft()) : viewport()->mapTo(m_pKviWindow, contentsRect().topLeft() + viewport()->contentsRect().topLeft());
p->drawTiledPixmap(contentsRect(),*(g_pShadedChildGlobalDesktopBackground), pnt);
}
delete p;
#endif
QTreeWidget::paintEvent(e);
}