本文整理汇总了C++中QWidget::backgroundPixmap方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::backgroundPixmap方法的具体用法?C++ QWidget::backgroundPixmap怎么用?C++ QWidget::backgroundPixmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::backgroundPixmap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::Paint){
QWidget *w = static_cast<QWidget*>(o);
for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
const QPixmap *bg = p->backgroundPixmap();
if (bg){
QPoint pos = w->mapToGlobal(QPoint(0, 0));
pos = p->mapFromGlobal(pos);
QRect rc(pos.x(), pos.y(), w->width(), w->height());
if (rc != rcChild){
rcChild = rc;
QPixmap new_bg(w->width(), w->height());
QPainter pp(&new_bg);
pp.drawTiledPixmap(0, 0, w->width(), w->height(), *bg, pos.x(), pos.y());
pp.end();
w->setBackgroundPixmap(new_bg);
}
if (w->backgroundPixmap()){
QPainter pp(w);
pp.drawPixmap(0, 0, *w->backgroundPixmap());
}
return true;
}
}
}
return false;
}
示例2: paintEvent
void ProxyConfig::paintEvent(QPaintEvent*)
{
for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
const QPixmap *bg = p->backgroundPixmap();
if (bg){
QPoint pos = mapToGlobal(QPoint(0, 0));
pos = p->mapFromGlobal(pos);
QPainter pp(this);
pp.drawTiledPixmap(0, 0, width(), height(), *bg, pos.x(), pos.y());
return;
}
}
QPainter pp(this);
pp.eraseRect(0, 0, width(), height());
}
示例3: background
QPixmap TransparentTop::background(const QColor &c)
{
#if COMPAT_QT_VERSION < 0x030000
QWidget *w = (QWidget*)parent();
const QPixmap *bg = w->backgroundPixmap();
if (bg == NULL || bg->isNull())
return QPixmap();
KPixmap pix(*bg);
#else
if (bg.isNull())
return QPixmap();
KPixmap pix(bg);
#endif
return KPixmapEffect::fade(pix, m_transparent, c);
}
示例4: background
QPixmap TransparentTop::background(const QColor &c)
{
#if COMPAT_QT_VERSION < 0x030000
QWidget *w = (QWidget*)parent();
const QPixmap *bg = w->backgroundPixmap();
if (bg == NULL)
return QPixmap();
QImage img = bg->toImage();
#else
if (bg.isNull())
return QPixmap();
QImage img = bg.toImage();
#endif
img = KImageEffect::fade(img, m_transparent, c);
QPixmap res;
res.fromImage(img);
return res;
}