本文整理汇总了C++中QSizeF::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizeF::width方法的具体用法?C++ QSizeF::width怎么用?C++ QSizeF::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizeF
的用法示例。
在下文中一共展示了QSizeF::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeHint
QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const {
if (which != Qt::PreferredSize || constraint.width() == -1)
return QGraphicsWidget::sizeHint(which, constraint);
else
return QSizeF( constraint.width(), constraint.width() );
}
示例2: reoriginCenterTopLeft
QPointF reoriginCenterTopLeft(const QPointF& origin,const QSizeF& size)
{
return realPointAsPixelPosition(origin-QPointF(realAsPixelSize(size.width()/2.0),realAsPixelSize(size.height()/2.0)));
}
示例3: realRectAroundRealPoint
QRectF realRectAroundRealPoint(const QSizeF& rectSize)
{
QPointF topleft = -QPointF(realPointAsPixelPosition(QPointF(rectSize.width()/2.0,rectSize.height()/2.0)));
return QRectF(topleft,rectSize);
}
示例4: draw
void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
applyStyle(p, states);
qreal oldOpacity = p->opacity();
p->setOpacity(oldOpacity * states.fillOpacity);
// Force the font to have a size of 100 pixels to avoid truncation problems
// when the font is very small.
qreal scale = 100.0 / p->font().pointSizeF();
Qt::Alignment alignment = states.textAnchor;
QTransform oldTransform = p->worldTransform();
p->scale(1 / scale, 1 / scale);
qreal y = 0;
bool initial = true;
qreal px = m_coord.x() * scale;
qreal py = m_coord.y() * scale;
QSizeF scaledSize = m_size * scale;
if (m_type == TEXTAREA) {
if (alignment == Qt::AlignHCenter)
px += scaledSize.width() / 2;
else if (alignment == Qt::AlignRight)
px += scaledSize.width();
}
QRectF bounds;
if (m_size.height() != 0)
bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.
bool appendSpace = false;
QVector<QString> paragraphs;
QStack<QTextCharFormat> formats;
QVector<QList<QTextLayout::FormatRange> > formatRanges;
paragraphs.push_back(QString());
formatRanges.push_back(QList<QTextLayout::FormatRange>());
for (int i = 0; i < m_tspans.size(); ++i) {
if (m_tspans[i] == LINEBREAK) {
if (m_type == TEXTAREA) {
if (paragraphs.back().isEmpty()) {
QFont font = p->font();
font.setPixelSize(font.pointSizeF() * scale);
QTextLayout::FormatRange range;
range.start = 0;
range.length = 1;
range.format.setFont(font);
formatRanges.back().append(range);
paragraphs.back().append(QLatin1Char(' '));;
}
appendSpace = false;
paragraphs.push_back(QString());
formatRanges.push_back(QList<QTextLayout::FormatRange>());
}
} else {
WhitespaceMode mode = m_tspans[i]->whitespaceMode();
m_tspans[i]->applyStyle(p, states);
QFont font = p->font();
font.setPixelSize(font.pointSizeF() * scale);
QString newText(m_tspans[i]->text());
newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
newText.replace(QLatin1Char('\n'), QLatin1Char(' '));
bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
if (appendSpace || prependSpace)
paragraphs.back().append(QLatin1Char(' '));
bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));
if (mode == Default) {
newText = newText.simplified();
if (newText.isEmpty())
appendSpaceNext = false;
}
QTextLayout::FormatRange range;
range.start = paragraphs.back().length();
range.length = newText.length();
range.format.setFont(font);
range.format.setTextOutline(p->pen());
range.format.setForeground(p->brush());
if (appendSpace) {
Q_ASSERT(!formatRanges.back().isEmpty());
++formatRanges.back().back().length;
} else if (prependSpace) {
--range.start;
++range.length;
}
formatRanges.back().append(range);
appendSpace = appendSpaceNext;
paragraphs.back() += newText;
m_tspans[i]->revertStyle(p, states);
//.........这里部分代码省略.........
示例5: _q_boundGeometryToSizeConstraints
static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
QRectF *rect, Qt::WindowFrameSection section,
const QSizeF &min, const QSizeF &max,
const QGraphicsWidget *widget)
{
const QRectF proposedRect = *rect;
qreal width = qBound(min.width(), proposedRect.width(), max.width());
qreal height = qBound(min.height(), proposedRect.height(), max.height());
const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight();
const bool widthChanged = proposedRect.width() != widget->size().width();
const bool heightChanged = proposedRect.height() != widget->size().height();
if (hasHFW || hasWFH) {
if (widthChanged || heightChanged) {
qreal minExtent;
qreal maxExtent;
qreal constraint;
qreal proposed;
if (hasHFW) {
minExtent = min.height();
maxExtent = max.height();
constraint = width;
proposed = proposedRect.height();
} else {
// width for height
minExtent = min.width();
maxExtent = max.width();
constraint = height;
proposed = proposedRect.width();
}
if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
width = effectiveSize.width();
height = effectiveSize.height();
}
}
}
switch (section) {
case Qt::LeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
qRound(width), startGeometry.height());
break;
case Qt::TopLeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
qRound(width), qRound(height));
break;
case Qt::TopSection:
rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
startGeometry.width(), qRound(height));
break;
case Qt::TopRightSection:
rect->setTop(rect->bottom() - qRound(height));
rect->setWidth(qRound(width));
break;
case Qt::RightSection:
rect->setWidth(qRound(width));
break;
case Qt::BottomRightSection:
rect->setWidth(qRound(width));
rect->setHeight(qRound(height));
break;
case Qt::BottomSection:
rect->setHeight(qRound(height));
break;
case Qt::BottomLeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
qRound(width), qRound(height));
break;
default:
break;
}
}
示例6: updateDeclarativeWebViewSize
void QDeclarativeWebView::updateDeclarativeWebViewSize()
{
QSizeF size = d->view->geometry().size() * contentsScale();
setImplicitWidth(size.width());
setImplicitHeight(size.height());
}
示例7: img
if ( m_haltFlag )
return;
}
QImage img( d->previewSize, QImage::Format_ARGB32 );
img.fill( Qt::transparent );
QPainter p( &img );
QSvgRenderer renderer( theme.graphicsFilePath() );
QSizeF size = renderer.boundsOnElement(QStringLiteral("back")).size();
size.scale( 1.5 * d->baseCardSize.width(), d->baseCardSize.height(), Qt::KeepAspectRatio );
qreal yPos = ( d->previewSize.height() - size.height() ) / 2;
qreal spacingWidth = d->baseCardSize.width()
* ( d->previewSize.width() - d->previewLayout.size() * size.width() )
/ ( d->previewSize.width() - d->previewLayout.size() * d->baseCardSize.width() );
qreal xPos = 0;
foreach ( const QList<QString> & pile, d->previewLayout )
{
foreach ( const QString & card, pile )
{
renderer.render( &p, card, QRectF( QPointF( xPos, yPos ), size ) );
xPos += 0.3 * spacingWidth;
}
xPos += 1 * size.width() + ( 0.1 - 0.3 ) * spacingWidth;
}
emit previewRendered( theme, img );
}
示例8: policy
//.........这里部分代码省略.........
on_mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() );
}
else // already a diagram renderer present
{
//single category renderer or interpolated one?
if ( dr->rendererName() == "SingleCategory" )
{
mFixedSizeRadio->setChecked( true );
}
else
{
mAttributeBasedScalingRadio->setChecked( true );
}
mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
mLinearScaleFrame->setEnabled( mAttributeBasedScalingRadio->isChecked() );
mCheckBoxAttributeLegend->setChecked( dr->attributeLegend() );
mCheckBoxSizeLegend->setChecked( dr->sizeLegend() );
mSizeLegendSymbol.reset( dr->sizeLegendSymbol() ? dr->sizeLegendSymbol()->clone() : QgsMarkerSymbolV2::createSimple( QgsStringMap() ) );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() );
mButtonSizeLegendSymbol->setIcon( icon );
//assume single category or linearly interpolated diagram renderer for now
QList<QgsDiagramSettings> settingList = dr->diagramSettings();
if ( !settingList.isEmpty() )
{
mDiagramFrame->setEnabled( settingList.at( 0 ).enabled );
mDiagramFont = settingList.at( 0 ).font;
QSizeF size = settingList.at( 0 ).size;
mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
mTransparencySpinBox->setValue( settingList.at( 0 ).transparency * 100.0 / 255.0 );
mTransparencySlider->setValue( mTransparencySpinBox->value() );
mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 );
// caution: layer uses scale denoms, widget uses true scales
mScaleRangeWidget->setScaleRange( 1.0 / ( settingList.at( 0 ).maxScaleDenominator > 0 ? settingList.at( 0 ).maxScaleDenominator : layer->maximumScale() ),
1.0 / ( settingList.at( 0 ).minScaleDenominator > 0 ? settingList.at( 0 ).minScaleDenominator : layer->minimumScale() ) );
mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType );
mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale );
mDiagramLineUnitComboBox->setUnit( settingList.at( 0 ).lineSizeUnit );
mDiagramLineUnitComboBox->setMapUnitScale( settingList.at( 0 ).lineSizeScale );
if ( settingList.at( 0 ).labelPlacementMethod == QgsDiagramSettings::Height )
{
mLabelPlacementComboBox->setCurrentIndex( 0 );
}
else
{
mLabelPlacementComboBox->setCurrentIndex( 1 );
}
mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).angleOffset ) );
mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left );
mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right );
mOrientationUpButton->setProperty( "direction", QgsDiagramSettings::Up );
mOrientationDownButton->setProperty( "direction", QgsDiagramSettings::Down );
switch ( settingList.at( 0 ).diagramOrientation )
{
case QgsDiagramSettings::Left:
mOrientationLeftButton->setChecked( true );
break;
case QgsDiagramSettings::Right:
mOrientationRightButton->setChecked( true );
示例9: legendIcon
/*!
\return Icon representing the curve on the legend
\param index Index of the legend entry
( ignored as there is only one )
\param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotCurve::legendIcon( int index,
const QSizeF &size ) const
{
Q_UNUSED( index );
if ( size.isEmpty() )
return QwtGraphic();
QwtGraphic graphic;
graphic.setDefaultSize( size );
graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
if ( d_data->legendAttributes == 0 ||
d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
{
QBrush brush = d_data->brush;
if ( brush.style() == Qt::NoBrush &&
d_data->legendAttributes == 0 )
{
if ( style() != QwtPlotCurve::NoCurve )
{
brush = QBrush( pen().color() );
}
else if ( d_data->symbol &&
( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
{
brush = QBrush( d_data->symbol->pen().color() );
}
}
if ( brush.style() != Qt::NoBrush )
{
QRectF r( 0, 0, size.width(), size.height() );
painter.fillRect( r, brush );
}
}
if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
{
if ( pen() != Qt::NoPen )
{
QPen pn = pen();
pn.setCapStyle( Qt::FlatCap );
painter.setPen( pn );
const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
}
}
if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
{
if ( d_data->symbol )
{
QRectF r( 0, 0, size.width(), size.height() );
d_data->symbol->drawSymbol( &painter, r );
}
}
return graphic;
}
示例10: setUniformVariable
void ShaderLibrary::setUniformVariable(GLuint /*program*/, GLint location, QSizeF const& value)
{
glUniform2f(location, value.width(), value.height());
}
示例11: QRectF
QRectF CurveItem::Marker::boundingRect() const
{
return QRectF(-markerSize.width() / 2, -markerSize.height() / 2, markerSize.width(), markerSize.height());
}
示例12: paint
void QgsLayoutItemLegend::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
{
if ( !painter )
return;
if ( mFilterAskedForUpdate )
{
mFilterAskedForUpdate = false;
doUpdateFilterByMap();
}
int dpi = painter->device()->logicalDpiX();
double dotsPerMM = dpi / 25.4;
if ( mLayout )
{
mSettings.setUseAdvancedEffects( mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagUseAdvancedEffects );
mSettings.setDpi( dpi );
}
if ( mMap && mLayout )
{
mSettings.setMmPerMapUnit( mLayout->convertFromLayoutUnits( mMap->mapUnitsToLayoutUnits(), QgsUnitTypes::LayoutMillimeters ).length() );
// use a temporary QgsMapSettings to find out real map scale
QSizeF mapSizePixels = QSizeF( mMap->rect().width() * dotsPerMM, mMap->rect().height() * dotsPerMM );
QgsRectangle mapExtent = mMap->extent();
QgsMapSettings ms = mMap->mapSettings( mapExtent, mapSizePixels, dpi, false );
mSettings.setMapScale( ms.scale() );
}
mInitialMapScaleCalculated = true;
QgsLegendRenderer legendRenderer( mLegendModel.get(), mSettings );
legendRenderer.setLegendSize( mForceResize && mSizeToContents ? QSize() : rect().size() );
//adjust box if width or height is too small
if ( mSizeToContents )
{
QSizeF size = legendRenderer.minimumSize();
if ( mForceResize )
{
mForceResize = false;
//set new rect, respecting position mode and data defined size/position
QgsLayoutSize newSize = mLayout->convertFromLayoutUnits( size, sizeWithUnits().units() );
attemptResize( newSize );
}
else if ( size.height() > rect().height() || size.width() > rect().width() )
{
//need to resize box
QSizeF targetSize = rect().size();
if ( size.height() > targetSize.height() )
targetSize.setHeight( size.height() );
if ( size.width() > targetSize.width() )
targetSize.setWidth( size.width() );
QgsLayoutSize newSize = mLayout->convertFromLayoutUnits( targetSize, sizeWithUnits().units() );
//set new rect, respecting position mode and data defined size/position
attemptResize( newSize );
}
}
QgsLayoutItem::paint( painter, itemStyle, pWidget );
}
示例13: convert
QVariant Property::convert(QVariant &value, QVariant::Type type) {
QVariant::Type v_type = value.type(); /// current variant type
QVariant c_value; /// converted value
QSize size;
QSizeF sizef;
QRect rect;
QRectF rectf;
QString string;
QStringList str_parts; /// Parts of string when parsing a string
c_value = value;
// Parse variant
switch (v_type) {
case QVariant::Size:
size = value.toSize();
switch (type) {
case QVariant::String:
c_value = QVariant(QString("%1,%2").arg(size.width()).arg(size.height()));
break;
default:
break;
}
break;
case QVariant::SizeF:
sizef = value.toSizeF();
switch (type) {
case QVariant::String:
c_value = QVariant(QString("%1,%2").arg(sizef.width()).arg(sizef.height()));
break;
default:
break;
}
break;
case QVariant::Rect:
rect = value.toRect();
switch (type) {
case QVariant::String:
c_value = QVariant(QString("%1,%2,%3,%4").arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height()));
break;
default:
break;
}
break;
case QVariant::RectF:
rectf = value.toRectF();
switch (type) {
case QVariant::String:
c_value = QVariant(QString("%1,%2,%3,%4").arg(rectf.x()).arg(rectf.y()).arg(rectf.width()).arg(rectf.height()));
break;
default:
break;
}
break;
case QVariant::String:
string = value.toString();
str_parts = string.split(",");
switch(type) {
case QVariant::Rect:
rect = QRect(str_parts[0].toInt(), str_parts[1].toInt(), str_parts[2].toInt(), str_parts[3].toInt());
c_value = QVariant(rect);
break;
case QVariant::RectF:
rectf = QRectF(str_parts[0].toFloat(), str_parts[1].toFloat(), str_parts[2].toFloat(), str_parts[3].toFloat());
c_value = QVariant(rectf);
break;
case QVariant::Size:
size = QSize(str_parts[0].toInt(), str_parts[1].toInt());
c_value = QVariant(size);
break;
case QVariant::SizeF:
sizef = QSizeF(str_parts[0].toFloat(), str_parts[1].toFloat());
c_value = QVariant(sizef);
break;
default:
break;
}
break;
default: // No (known) need for processing
break;
}
return c_value;
}
示例14: _q_boundGeometryToSizeConstraints
static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
QRectF *rect, Qt::WindowFrameSection section,
const QSizeF &min, const QSizeF &max,
const QGraphicsWidget *widget)
{
const QRectF proposedRect = *rect;
qreal width = qBound(min.width(), proposedRect.width(), max.width());
qreal height = qBound(min.height(), proposedRect.height(), max.height());
QSizePolicy sp = widget->sizePolicy();
if (const QGraphicsLayout *l = widget->layout()) {
sp = l->sizePolicy();
}
const bool hasHFW = sp.hasHeightForWidth(); // || sp.hasWidthForHeight();
const bool widthChanged = proposedRect.width() < widget->size().width();
const bool heightChanged = proposedRect.height() < widget->size().height();
if (hasHFW) {
if (widthChanged || heightChanged) {
const qreal minh = min.height();
const qreal maxh = max.height();
const qreal proposedHFW = minimumHeightForWidth(width, minh, maxh, widget);
if (proposedHFW > proposedRect.height()) {
QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
width = effectiveSize.width();
height = effectiveSize.height();
}
}
}
switch (section) {
case Qt::LeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
qRound(width), startGeometry.height());
break;
case Qt::TopLeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
qRound(width), qRound(height));
break;
case Qt::TopSection:
rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
startGeometry.width(), qRound(height));
break;
case Qt::TopRightSection:
rect->setTop(rect->bottom() - qRound(height));
rect->setWidth(qRound(width));
break;
case Qt::RightSection:
rect->setWidth(qRound(width));
break;
case Qt::BottomRightSection:
rect->setWidth(qRound(width));
rect->setHeight(qRound(height));
break;
case Qt::BottomSection:
rect->setHeight(qRound(height));
break;
case Qt::BottomLeftSection:
rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
qRound(width), qRound(height));
break;
default:
break;
}
}
示例15: QSize
static inline QSize qCeiling(const QSizeF &s)
{
return QSize(qCeil(s.width()), qCeil(s.height()));
}