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


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

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


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

示例1: requestPixmap

QPixmap ThemeAccessor::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
    (void) requestedSize;

    QPixmap ret;

    if (id.startsWith("avatar/")) {
        return m_theme->trainerSprite(id.section("/", 1).toInt());
    }

    *size = ret.size();

    return ret;
}
开发者ID:Alicirno,项目名称:pokemon-online,代码行数:14,代码来源:themeaccessor.cpp

示例2: requestPixmap

QPixmap CloudImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize)
{
    QString rsrcid = ":/" + id;
    QPixmap image(rsrcid);
    QPixmap result;

    if (requestedSize.isValid()) {
        result = image.scaled(requestedSize, Qt::KeepAspectRatio);
    } else {
        result = image;
    }
    *size = result.size();
    return result;
}
开发者ID:pockemul,项目名称:PockEmul,代码行数:14,代码来源:cloudimageprovider.cpp

示例3: computeMargins

void KMultiTabBarTab::computeMargins(int* hMargin, int* vMargin) const
{
	// Unfortunately, QStyle does not give us enough information to figure out
	// where to place things, so we try to reverse-engineer it
	QStyleOptionToolButton opt;
	initStyleOption(&opt);

	QPixmap iconPix = iconPixmap();
	QSize trialSize = iconPix.size();
	QSize expandSize = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, trialSize, this);

	*hMargin = (expandSize.width()  - trialSize.width())/2;
	*vMargin = (expandSize.height() - trialSize.height())/2;
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:14,代码来源:kmultitabbar.cpp

示例4: mouseMoveEvent

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PipelineFilterWidget::mouseMoveEvent(QMouseEvent* event)
{
    if(!(event->buttons() & Qt::LeftButton))
    {
        return;
    }
    if((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
    {
        return;
    }
    // The user is dragging the filter widget so we should set it as selected.
    setIsSelected(true);
    QPixmap pixmap = grab();

    // Create new picture for transparent
    QPixmap transparent(pixmap.size());
    // Do transparency
    transparent.fill(Qt::transparent);
#if 1
    QPainter p;
    p.begin(&transparent);
    p.setOpacity(0.70);
    p.drawPixmap(0, 0, pixmap);
    p.end();
#endif

    QByteArray itemData;
    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
    dataStream << transparent << QPoint(event->pos());

    QMimeData* mimeData = new QMimeData;
    mimeData->setData("application/x-dnditemdata", itemData);

    QDrag* drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(transparent);
    drag->setHotSpot(event->pos());

    emit dragStarted(this);

    //  if(drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
    //  {
    //    qDebug() << "Drag should close the widget because it was MOVE" << "\n";
    //  }
    //  else
    //  {
    //    qDebug() << "Drag should leave Widget alone because it was COPY" << "\n";
    //  }
    drag->exec(Qt::MoveAction);
}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:53,代码来源:PipelineFilterWidget.cpp

示例5: exportToPNG

void ModelExportHelper::exportToPNG(ObjectsScene *scene, const QString &filename, bool show_grid, bool show_delim)
{
	if(!scene)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	try
	{
		QPixmap pix;
		QRectF ret=scene->itemsBoundingRect();
		bool shw_grd, shw_dlm, align_objs;

		//Make a backup of the current scene options
		ObjectsScene::getGridOptions(shw_grd, align_objs, shw_dlm);

		//Sets the options passed by the user
		ObjectsScene::setGridOptions(show_grid, false, show_delim);

		//Ceils the width and height of scene rectangle in order to not draw dirty areas on pixmap
		ret.setWidth(ceilf(ret.width()));
		ret.setHeight(ceilf(ret.height()));

		//Creates the output pixmap
		pix=QPixmap(ret.size().toSize());
		QPainter p(&pix);

		//Setting optimizations on the painter
		p.setRenderHint(QPainter::Antialiasing, true);
		p.setRenderHint(QPainter::TextAntialiasing, true);
		p.setRenderHint(QPainter::SmoothPixmapTransform, true);

		//Render the entire scene onto the pixmap
		scene->clearSelection();
		scene->update();
		scene->render(&p, QRectF(QPointF(0,0), pix.size()), ret);

		//Restore the scene options
		ObjectsScene::setGridOptions(shw_grd, align_objs, shw_dlm);
		scene->update();

		//If the pixmap is not saved raises an error
		if(!pix.save(filename))
			throw Exception(Exception::getErrorMessage(ERR_FILE_NOT_WRITTEN).arg(Utf8String::create(filename)),
											ERR_FILE_NOT_WRITTEN,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:inghumberto,项目名称:pgmodeler,代码行数:49,代码来源:modelexporthelper.cpp

示例6: getPixmapForIndex

QPixmap GPSImageModel::getPixmapForIndex(const QPersistentModelIndex& itemIndex, const int size)
{
    if (itemIndex.isValid())
    {
        Q_ASSERT(itemIndex.model() == this);
    }

    // TODO: should we cache the pixmap on our own here or does the interface usually cache it for us?
    // TODO: do we need to make sure we do not request the same pixmap twice in a row?
    // construct the key under which we stored the pixmap in the cache:
    GPSImageItem* const imageItem = itemFromIndex(itemIndex);

    if (!imageItem)
        return QPixmap();

    QPixmap thumbnail;

    if (d->thumbnailLoadThread->find(ThumbnailIdentifier(imageItem->url().toLocalFile()), thumbnail, size))
    {
        return thumbnail.copy(1, 1, thumbnail.size().width()-2, thumbnail.size().height()-2);
    }

    return QPixmap();
}
开发者ID:KDE,项目名称:digikam,代码行数:24,代码来源:gpsimagemodel.cpp

示例7: drawDecoration

void KWQTableDelegate::drawDecoration(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QPixmap& pixmap) const
{
  if (pixmap.isNull() || !rect.isValid())
    return;
  QPoint p = QStyle::alignedRect(option.direction, option.decorationAlignment, pixmap.size(), rect).topLeft();
  QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
  if (option.state & QStyle::State_Selected) {
    painter->fillRect(rect, option.palette.brush(cg, option.state & QStyle::State_HasFocus ?
          QPalette::Base : QPalette::Highlight));
    QPixmap *pm = selected(pixmap, option.palette, option.state & QStyle::State_Enabled);
    painter->drawPixmap(p, *pm);
  } else {
    painter->drawPixmap(p, pixmap);
  }
}
开发者ID:phedlund,项目名称:kwordquiz,代码行数:15,代码来源:kwqtabledelegate.cpp

示例8: QLabel

LinkLabel::LinkLabel(const QPixmap& upImg, const QPixmap& downImg, QString text, QWidget* parent)
    : QLabel(parent)
{
    _upImg = upImg;
    _downImg = downImg;
    setPixmap(_upImg);
    setFixedSize(upImg.size());
    _down = false;
    _enabled = true;
    _checkable = false;
    _type = false;
    _tooltip = text;
    _hyperlink = true;
    setMouseTracking(true);
}
开发者ID:dmosora,项目名称:Query-Dependent,代码行数:15,代码来源:LinkLabel.cpp

示例9: requestPixmap

    QPixmap GlobalImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    {
        QPixmap image(id);
        QPixmap result;

        if (requestedSize.isValid()) {
            result = image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        else {
            result = image;
        }

        *size = result.size();
        return result;
    }
开发者ID:snikolau,项目名称:xpiks,代码行数:15,代码来源:globalimageprovider.cpp

示例10: QGraphicsScene

MyScene::MyScene() : QGraphicsScene()
{
	QString fichier = QFileDialog::getOpenFileName(0, "Ouvrir un fichier", QString(), "Images (*.png *.gif *.jpg *.jpeg)");
	QPixmap image = QPixmap(fichier);
	size = image.size();
	
	impix=addPixmap(image);

	point1 = QPointF();
	point2 = QPointF();
	numero=true;
	MyRectItem=new QGraphicsRectItem;
	rect = QRectF();

}
开发者ID:jbfiot,项目名称:rangers,代码行数:15,代码来源:MyScene.cpp

示例11: addDropDownIndicator

QPixmap RoutingInputWidgetPrivate::addDropDownIndicator(const QPixmap &pixmap)
{
    QPixmap result( pixmap.size() + QSize( 8, pixmap.height() ) );
    result.fill( QColor( Qt::transparent ) );
    QPainter painter( &result );
    painter.drawPixmap( 0, 0, pixmap );
    QPoint const one( pixmap.width() + 1, pixmap.height() - 8 );
    QPoint const two( one.x() + 6, one.y() );
    QPoint const three( one.x() + 3, one.y() + 4 );
    painter.setRenderHint( QPainter::Antialiasing, true );
    painter.setPen( Qt::NoPen );
    painter.setBrush( QColor( Oxygen::aluminumGray4 ) );
    painter.drawConvexPolygon( QPolygon() << one << two << three );
    return result;
}
开发者ID:KDE,项目名称:marble,代码行数:15,代码来源:RoutingInputWidget.cpp

示例12: slotThumbnailLoaded

void GPSImageModel::slotThumbnailLoaded(const LoadingDescription& loadingDescription, const QPixmap& thumb)
{
    if (thumb.isNull())
    {
        return;
    }

    const QModelIndex currentIndex = indexFromUrl(QUrl::fromLocalFile(loadingDescription.filePath));

    if (currentIndex.isValid())
    {
        QPersistentModelIndex goodIndex(currentIndex);
        emit(signalThumbnailForIndexAvailable(goodIndex, thumb.copy(1, 1, thumb.size().width()-2, thumb.size().height()-2)));
    }
}
开发者ID:KDE,项目名称:digikam,代码行数:15,代码来源:gpsimagemodel.cpp

示例13: painter

QPixmap * RazorDeskIconBase::initialPainting(QIcon::Mode mode)
{
    qDebug() << "RazorDeskIconBase::initialPainting";
    
    if (icon().isNull())
    {
        qDebug() << "RazorDeskIconBase::setPos - icon() is null. Skipping for now.";
        return 0;
    }
    
    QPixmap * pm = new QPixmap(70, 70);
    pm->fill(QColor(0,0,0,0));

    QPainter painter(pm);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setRenderHint(QPainter::HighQualityAntialiasing);
    painter.setRenderHint(QPainter::NonCosmeticDefaultPen);
    
    // now the icon
    QPixmap appIcon = icon().pixmap(iconSize(), mode);
    // HACK: in some cases we can get larger icon than expected so rescale
    //       it with brute force if it's required...
    if (appIcon.size().width() > iconSize().width())
        appIcon = appIcon.scaled(iconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

    QRect source(0, 0, 32, 32);
    int w = pm->width() / 2;
    int h = pm->height() / 2;
    int iw = iconSize().width() / 2;
    int ih = iconSize().height() / 2;
    QRect target(w - iw, h - ih - 10,
                 iconSize().width(), iconSize().height());
    painter.drawPixmap(target, appIcon, source);

    // text now - it has to follow potential QSS
    QColor txt = palette().color(QPalette::WindowText);
    painter.setPen(txt);
    painter.setBrush(palette().color(QPalette::Window));
    painter.drawText(QRectF(2, h+ih-10, pm->width()-4, pm->height()-h-ih+10),
                     Qt::AlignCenter | Qt::TextWordWrap | Qt::TextIncludeTrailingSpaces | Qt::TextDontClip,
                     text());
    painter.end();

    pm->setMask(pm->createHeuristicMask());
    setMask(pm->mask());
    
    return pm;
}
开发者ID:Alexandr-Galko,项目名称:razor-qt,代码行数:48,代码来源:razordeskicon.cpp

示例14: XLet

DialPanel::DialPanel(QWidget *parent)
    : XLet(parent)
{
    setTitle(tr("Dial"));
    setAccessibleName(tr("Dial Panel"));

    setAcceptDrops(true);

    m_input = new QComboBox(this);
    m_input->setObjectName("extension_input");
    m_input->setToolTip(tr("Input here the phone number to dial"));
    m_input->setEditable(true);
    m_input->setDuplicatesEnabled(false);
    m_input->setInsertPolicy(QComboBox::InsertAtTop);
    m_input->setMinimumContentsLength(15);
    m_input->lineEdit()->setMaxLength(30);

    m_lbl = new QLabel(tr("Enter &Number :"), this);
    m_lbl->setBuddy(m_input);

    loadHistory();
    m_input->clearEditText();

    QPixmap pmphone = QPixmap(":/images/sipphone.png");
    QPushButton * dialButton = new QPushButton(this);
    dialButton->setObjectName("dial_button");
    dialButton->setIcon(pmphone);
    dialButton->setIconSize(pmphone.size());

    QHBoxLayout * vlayout = new QHBoxLayout(this);
    vlayout->setMargin(0);
    vlayout->addStretch(1);
    vlayout->addWidget(m_lbl, 0, Qt::AlignCenter);
    vlayout->addWidget(m_input, 0, Qt::AlignCenter);
    vlayout->addWidget(dialButton, 0, Qt::AlignCenter);
    vlayout->addStretch(1);

    connect(dialButton, SIGNAL(clicked()),
            m_input->lineEdit(), SIGNAL(returnPressed()));
    connect(b_engine, SIGNAL(pasteToXlets(const QString &)),
            this, SLOT(setNumberToDial(const QString &)));
    connect(this, SIGNAL(textEdited(const QString &)),
            b_engine, SLOT(textEdited(const QString &)));
    connect(m_input->lineEdit(), SIGNAL(returnPressed()),
            this, SLOT(inputValidated()));
    connect(m_input, SIGNAL(editTextChanged(const QString &)),
            this, SIGNAL(textEdited(const QString &)));
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例15: resetIcons

void MontageView::resetIcons()
{
  if( !m_dirty )
    return;

  m_dirty = false;

  // FixMe: This should be optimized by caching the old images instead
  for( QIconViewItem* item = firstItem(); item; item = item->nextItem() ) {
    QPixmap pm = *item->pixmap();
    QSize size = pm.size();
    QImage icon( item->text() );
    pm = icon.smoothScale( size );
  }

}
开发者ID:Zitrax,项目名称:peru,代码行数:16,代码来源:MontageView.cpp


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