当前位置: 首页>>代码示例>>C++>>正文


C++ QPixmap::fill方法代码示例

本文整理汇总了C++中QPixmap::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::fill方法的具体用法?C++ QPixmap::fill怎么用?C++ QPixmap::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPixmap的用法示例。


在下文中一共展示了QPixmap::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findComboButton

QPixmap StylePainterMobile::findComboButton(const QSize& size, bool multiple, bool enabled) const
{
    if (size.isNull())
        return QPixmap();
    QPixmap result;
    KeyIdentifier id;
    id.type = KeyIdentifier::ComboButton;
    id.width = size.width();
    id.height = size.height();
    id.trait1 = multiple;
    id.trait2 = enabled;

    if (!findCachedControl(id, &result)) {
        result = QPixmap(size);
        const qreal border = painterScale(painter);
        const QSizeF padding(2 * border, 2 * border);
        const QSizeF innerSize = size - padding;
        ASSERT(innerSize.isValid());
        result.fill(Qt::transparent);
        QPainter cachePainter(&result);
        cachePainter.translate(border, border);
        if (multiple)
            drawMultipleComboButton(&cachePainter, innerSize, enabled ? darkColor : Qt::lightGray);
        else
            drawSimpleComboButton(&cachePainter, innerSize, enabled ? darkColor : Qt::lightGray);
        insertIntoCache(id, result);
    }
    return result;
}
开发者ID:dog-god,项目名称:iptv,代码行数:29,代码来源:RenderThemeQtMobile.cpp

示例2: renderSpecial

QPixmap Renderer::renderSpecial(SpecialType type, int size) const {
	if(!m_renderer->isValid() || size == 0) return QPixmap();
	
	//only show the errors if the option has been set
	if(!Settings::showErrors() && type == SpecialCellMistake ) type = SpecialCell;
	
	QString cacheName = QString("special_%1_%2").arg(m_specialNames[type]).arg(size);
	QPixmap pix;
	if(!m_cache->find(cacheName, pix)) {
		pix = QPixmap(size, size);
		pix.fill(Qt::transparent);
		QPainter p(&pix);
		
		// NOTE fix for Qt's QSvgRenderer size reporting bug
		QRectF r(m_renderer->boundsOnElement(m_specialNames[type]));
		QRectF from(r.adjusted(+0.5,+0.5,-0.5,-0.5));
		QRectF to(QRectF(0,0,size,size));
		r.setTopLeft(fromRectToRect(r.topLeft(), from, to));
		r.setBottomRight(fromRectToRect(r.bottomRight(), from, to));
		
		m_renderer->render(&p, m_specialNames[type], r);
		p.end();
		m_cache->insert(cacheName, pix);
	}

	return pix;
}
开发者ID:KDE,项目名称:ksudoku,代码行数:27,代码来源:renderer.cpp

示例3: outlineText

QPixmap NumberChoiceLive::outlineText(QString text) {
	QPixmap *canvas = new QPixmap(200,200);
	canvas->fill(Qt::transparent);
	
	QFont font;
	font.setPointSize(60);
	font.setBold(true);
	
	QPen pen; // Give a nice black outline
	pen.setWidth(5);
	
	QPainterPath path; // Have to use path to get an outline
	path.addText(0,90, font, text);
	
	QPainter painter(canvas); // Make the outlines text
	painter.setBrush(QBrush(Qt::yellow));
	painter.setPen(pen);
	painter.setRenderHint(QPainter::Antialiasing);
	painter.drawPath(path);
	
	painter.setFont(font); // Remove the rubbish from the image so we only have the text
	QRect textBounds = painter.boundingRect(canvas->rect(), 0, text);
	
	return canvas->copy(textBounds);
}
开发者ID:davidpuzey,项目名称:peanuts,代码行数:25,代码来源:NumberChoiceModule.cpp

示例4: setImage

void TreeItem::setImage(const QIcon &icon, int column)
{
  if (column<13&&column>-1)
  {
    if (column==1)
    {
      int size=24;
      QSize ava_size(size,size);
      QPixmap pixmap = icon.pixmap(icon.actualSize(QSize(65535,65535)),QIcon::Normal,QIcon::On);
      if (!pixmap.isNull())
      {
        QPixmap alpha (ava_size);
        alpha.fill(QColor(0,0,0));
        QPainter painter(&alpha);
        QPen pen(QColor(127,127,127));
        painter.setRenderHint(QPainter::Antialiasing);
        pen.setWidth(0);
        painter.setPen(pen);
        painter.setBrush(QBrush(QColor(255,255,255)));
        painter.drawRoundRect(QRectF(QPointF(0,0),QSize(size-1,size-1)),5,5);
        painter.end();
        pixmap = pixmap.scaled(ava_size,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
        pixmap.setAlphaChannel(alpha);
        m_item_icons[column] = QIcon(pixmap);
      }
      return;
    }
    if (column==0)
      m_current_status_icon=icon;
    m_item_icons[column] = icon;
  }
}
开发者ID:RankoR,项目名称:mqutim,代码行数:32,代码来源:treeitem.cpp

示例5: pixmapRect

Thumbnail::Thumbnail(const QPixmap &originalPixmap)
{
	QPixmap pixmap = originalPixmap.scaled(PixmapSize, PixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
	QPixmap shadow;
	QRect pixmapRect(Margin + PixmapSize / 2 - pixmap.size().width() / 2, Margin + PixmapSize / 2 - pixmap.size().height() / 2, pixmap.size().width(), pixmap.size().height());
	
	if (_shadowCache.contains(pixmap.size()))
	{
		shadow = _shadowCache.value(pixmap.size());
	}
	else
	{
		shadow = QPixmap(thumbnailSize());
		shadow.fill(Qt::transparent);
		
		QGraphicsScene scene(shadow.rect());
		auto rectItem = scene.addRect(pixmapRect, Qt::NoPen, Qt::white);
		QGraphicsDropShadowEffect effect(0);
		effect.setBlurRadius(6);
		effect.setOffset(0);
		rectItem->setGraphicsEffect(&effect);
		
		QPainter painter(&shadow);
		scene.render(&painter);
		painter.end();
		
		_shadowCache.insert(pixmap.size(), shadow);
	}
	
	_thumbnail = shadow;
	QPainter painter(&_thumbnail);
	painter.drawPixmap(pixmapRect.topLeft(), pixmap);
}
开发者ID:h2so5,项目名称:PaintField,代码行数:33,代码来源:thumbnail.cpp

示例6: p

void Cmap_button::scale_icon_to_128()
{
    //drawing a beautiful this->zoomlevel * 64 -10 pixmap/icon
    //drawing the scaled image
    QPixmap face = QPixmap( 118, 118 );
    face.fill( Qt::transparent );
    QImage img = this->icon.scaled( QSize( 118,118 ), Qt::KeepAspectRatio );
    QPainter p( &face );
    p.drawImage( QPoint( (118 - img.width()) / 2, (118 -img.height() )) / 2, img );
    //drawing the framed text
    p.setPen( QColor( 42, 42, 42, 200 ) );
    //l shadow
    p.drawText( QRect( -1, 59, 117, 59 ), Qt::AlignCenter, this->text );
    //r shaodw
    p.drawText( QRect( 1, 59, 119, 59 ), Qt::AlignCenter, this->text );
    //u shadow
    p.drawText( QRect( 0, 58, 118, 58 ), Qt::AlignCenter, this->text );
    //d shadow
    p.drawText( QRect( 0, 60, 118, 60 ), Qt::AlignCenter, this->text );

    p.setPen( Qt::white );
    p.drawText( QRect( 0, 59, 118, 59 ), Qt::AlignCenter, this->text );
    p.end();
    this->rendered_face = face;
    this->setIconSize( QSize( 118, 118 ) );
    this->setFixedSize( 128,128 );
    this->setIcon( QIcon( face ) );
}
开发者ID:axed,项目名称:gnurpgm,代码行数:28,代码来源:cmap_array_widget.cpp

示例7: connectionColorPixmap

    QPixmap connectionColorPixmap(const QString & name)
    {
        QPixmap pm;
        if (name.isNull() || name.isEmpty())
            return pm;
        if (!QPixmapCache::find(name, pm))
        {
            // draw a "cool 3d" bullet here
            pm = QPixmap(16, 16);
            pm.fill(Qt::transparent);
            QColor col(name);

            QPainter painter(&pm);
            painter.setRenderHints(QPainter::HighQualityAntialiasing);
            QRadialGradient brush(16 / 2, 16 / 2, 16 * 1.5, 16 / 2, 16 / 4);
            brush.setColorAt(0, col.lighter());
            brush.setColorAt(0.2, col);
            brush.setColorAt(0.6, col.darker());
            brush.setColorAt(1, Qt::black);
            painter.setBrush(brush);

            QPen pen(Qt::black);
            pen.setWidth(1);
            pen.setCosmetic(true);
            painter.setPen(pen);

            painter.drawEllipse(1, 1, 14, 14);
            painter.end();

            QPixmapCache::insert(name, pm);
        }
        return pm;
    }
开发者ID:Daniel1892,项目名称:tora,代码行数:33,代码来源:utils.cpp

示例8: setFont

	/**
	 * Changes the font associated with this item.
	 * The function a sample text on a pixmap using this font, and then
	 * assigns the pixmap to the list item.
	 * The font set by this function is returned by getFont().
	 * @param	font	The font to set
	 */
	void setFont(QFont font) {
		QPixmap pix;
		QFontMetrics fm(font);
		QPainter painter;
		QRect rc;
		
		// Remember the font
		m_font = font;
		
		// Set the pixmap's size so it can contain the sample text
		rc = fm.boundingRect(i18n("Sample"));
		rc.moveTopLeft(QPoint(0, 0));
		pix.resize(rc.width(), rc.height());
		
		// Draw on the pixmap
		pix.fill();
		painter.begin(&pix);
		painter.setFont(font);
		painter.setPen(black);
		painter.drawText(rc, Qt::AlignHCenter | Qt::AlignVCenter,
			i18n("Sample"));
		painter.end();
		
		// Set the pixmap to the item
		setPixmap(1, pix);
	}
开发者ID:VicHao,项目名称:kkscope,代码行数:33,代码来源:preffont.cpp

示例9: pixmap

void CSVWidget::SceneToolToggle::adjustIcon()
{
    unsigned int selection = getSelectionMask();
    if (!selection)
        setIcon (QIcon (QString::fromUtf8 (mEmptyIcon.c_str())));
    else
    {
        QPixmap pixmap (48, 48);
        pixmap.fill (QColor (0, 0, 0, 0));

        {
            QPainter painter (&pixmap);

            for (std::map<PushButton *, ButtonDesc>::const_iterator iter (mButtons.begin());
                iter!=mButtons.end(); ++iter)
                if (iter->first->isChecked())
                {
                    painter.drawImage (getIconBox (iter->second.mIndex),
                        QImage (QString::fromUtf8 (iter->second.mSmallIcon.c_str())));
                }
        }

        setIcon (pixmap);
    }
}
开发者ID:A1-Triard,项目名称:openmw,代码行数:25,代码来源:scenetooltoggle.cpp

示例10: drawCheckBox

static QIcon drawCheckBox(bool value)
{
	QStyleOptionButton opt;
	opt.state |= value ? QStyle::State_On : QStyle::State_Off;
	opt.state |= QStyle::State_Enabled;
	const QStyle *style = QApplication::style();
	// Figure out size of an indicator and make sure it is not scaled down in a list view item
	// by making the pixmap as big as a list view icon and centering the indicator in it.
	// (if it is smaller, it can't be helped)
	const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt);
	const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt);
	const int listViewIconSize = indicatorWidth;
	const int pixmapWidth = indicatorWidth;
	const int pixmapHeight = qMax(indicatorHeight, listViewIconSize);

	opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight);
	QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight);
	pixmap.fill(Qt::transparent);
	{
		// Center?
		const int xoff = (pixmapWidth  > indicatorWidth)  ? (pixmapWidth  - indicatorWidth)  / 2 : 0;
		const int yoff = (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0;
		QPainter painter(&pixmap);
		painter.translate(xoff, yoff);
		style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter);
	}
	return QIcon(pixmap);
}
开发者ID:ldraw-linux,项目名称:leocad,代码行数:28,代码来源:lc_qpropertiestree.cpp

示例11: drawDisplay

/*!
    \reimp
 */
void QxtItemDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QString& text) const
{
    if (!Qt::mightBeRichText(text))
    {
        QItemDelegate::drawDisplay(painter, option, rect, text);
        return;
    }

    QString key = QString(QLatin1String("QxtItemDelegate:%1")).arg(text);
    QPixmap pixmap;
    if (!QPixmapCache::find(key, pixmap))
    {
        if (!qxt_d().document)
            qxt_d().document = new QTextDocument(const_cast<QxtItemDelegate*>(this));
        qxt_d().document->setHtml(text);
        qxt_d().document->adjustSize();

        pixmap = QPixmap(qxt_d().document->size().toSize());
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        qxt_d().document->drawContents(&painter);
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    painter->drawPixmap(option.rect.topLeft(), pixmap);
}
开发者ID:MiniMonster,项目名称:Mini-Monster_PC_control,代码行数:29,代码来源:qxtitemdelegate.cpp

示例12: setImageInfo

void djvFileBrowserItem::setImageInfo(
    const djvImageIoInfo &  imageInfo,
    const djvVector2i &     thumbnailSize,
    djvPixelDataInfo::PROXY thumbnailProxy)
{
    //DJV_DEBUG("djvFileBrowserItem::setImageInfo");
    //DJV_DEBUG_PRINT("image info = " << imageInfo);
    //DJV_DEBUG_PRINT("thumbnail size = " << thumbnailSize);
    //DJV_DEBUG_PRINT("thumbnail proxy = " << thumbnailProxy);
        
    _imageInfo      = imageInfo;
    _thumbnailSize  = thumbnailSize;
    _thumbnailProxy = thumbnailProxy;
    
    _displayRole[djvFileBrowserModel::NAME] =
        QString("%1\n%2x%3:%4 %5\n%[email protected]%7").
            arg(_fileInfo.name()).
            arg(_imageInfo.size.x).
            arg(_imageInfo.size.y).
            arg(djvVectorUtil::aspect(_imageInfo.size), 0, 'f', 2).
            arg(djvStringUtil::label(_imageInfo.pixel).join(", ")).
            arg(djvTime::frameToString(
                _imageInfo.sequence.frames.count(),
                _imageInfo.sequence.speed)).
            arg(djvSpeed::speedToFloat(_imageInfo.sequence.speed));

    _thumbnail = QPixmap(_thumbnailSize.x, _thumbnailSize.y);
    _thumbnail.fill(Qt::transparent);
}
开发者ID:triceratops1,项目名称:djv,代码行数:29,代码来源:djvFileBrowserModel.cpp

示例13: fade

    //________________________________________________
    void TransitionWidget::fade( const QPixmap& source, QPixmap& target, qreal opacity, const QRect& rect ) const
    {

        if( target.isNull() || target.size() != size() )
        { target = QPixmap( size() ); }

        // erase target
        target.fill( Qt::transparent );

        // check opacity
        if( opacity*255 < 1 ) return;

        QPainter p( &target );
        p.setClipRect( rect );

        // draw pixmap
        p.drawPixmap( QPoint(0,0), source );

        // opacity mask (0.996 corresponds to 254/255)
        if( opacity <= 0.996 )
        {
            p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
            QColor color( Qt::black );
            color.setAlphaF( opacity );
            p.fillRect(rect, color );
        }

        p.end();
        return;
    }
开发者ID:iamjamestl,项目名称:breeze,代码行数:31,代码来源:breezetransitionwidget.cpp

示例14: findLineEdit

QPixmap StylePainterMobile::findLineEdit(const QSize & size, bool focused) const
{
    QPixmap result;
    KeyIdentifier id;
    id.type = KeyIdentifier::LineEdit;
    id.width = size.width();
    id.height = size.height();
    id.trait1 = focused;

    if (!findCachedControl(id, &result)) {
        const int focusFrame = painterScale(painter);
        result = QPixmap(size);
        result.fill(Qt::transparent);
        const QRect rect = result.rect().adjusted(focusFrame, focusFrame, -focusFrame, -focusFrame);
        QPainter cachePainter(&result);
        drawControlBackground(&cachePainter, borderPen(painter), rect, Qt::white);

        if (focused) {
            QPen focusPen(highlightColor, 1.2 * painterScale(painter), Qt::SolidLine);
            drawControlBackground(&cachePainter, focusPen, rect, Qt::NoBrush);
        }
        insertIntoCache(id, result);
    }
    return result;
}
开发者ID:dog-god,项目名称:iptv,代码行数:25,代码来源:RenderThemeQtMobile.cpp

示例15: UpdatePreView

void PolygonWidget::UpdatePreView()
{
	double roundness = CurvatureSpin->value() / 100.0;
	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
	pm.fill(Qt::white);
	QPainter p;
	p.begin(&pm);
	p.setBrush(Qt::NoBrush);
	p.setPen(Qt::black);
	QPainterPath pp = RegularPolygon(Preview->width() - 6, Preview->height() - 6, Ecken->value(), Konvex->isChecked(), GetFaktor(), Slider2->value(), roundness);
	QRectF br = pp.boundingRect();
	if (br.x() < 0)
	{
		QMatrix m;
		m.translate(-br.x(), 0);
		pp = pp * m;
	}
	if (br.y() < 0)
	{
		QMatrix m;
		m.translate(0, -br.y());
		pp = pp * m;
	}
	br = pp.boundingRect();
	if ((br.height() > Preview->height() - 6) || (br.width() > Preview->width() - 6))
	{
		QMatrix ma;
		double sca = static_cast<double>(qMax(Preview->height() - 6, Preview->width() - 6)) / static_cast<double>(qMax(br.width(), br.height()));
		ma.scale(sca, sca);
		pp = pp * ma;
	}
	p.strokePath(pp, p.pen());
	p.end();
	Preview->setPixmap(pm);
}
开发者ID:pvanek,项目名称:scribus-cuba-1.5.0,代码行数:35,代码来源:polygonwidget.cpp


注:本文中的QPixmap::fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。