本文整理汇总了C++中QSizeF::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizeF::isValid方法的具体用法?C++ QSizeF::isValid怎么用?C++ QSizeF::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizeF
的用法示例。
在下文中一共展示了QSizeF::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeToChild
bool KWidget::sizeToChild()
{
QSizeF mins = minimumSize();
QSizeF maxs = maximumSize();
if(mins.isValid() && maxs.isValid())
return false;
return true;
}
示例2: qwtDrawSvgSymbols
static inline void qwtDrawSvgSymbols( QPainter *painter,
const QPointF *points, int numPoints,
QSvgRenderer *renderer, const QwtSymbol &symbol )
{
if ( renderer == NULL || !renderer->isValid() )
return;
const QRectF viewBox = renderer->viewBoxF();
if ( viewBox.isEmpty() )
return;
QSizeF sz = symbol.size();
if ( !sz.isValid() )
sz = viewBox.size();
const double sx = sz.width() / viewBox.width();
const double sy = sz.height() / viewBox.height();
QPointF pinPoint = viewBox.center();
if ( symbol.isPinPointEnabled() )
pinPoint = symbol.pinPoint();
const double dx = sx * ( pinPoint.x() - viewBox.left() );
const double dy = sy * ( pinPoint.y() - viewBox.top() );
for ( int i = 0; i < numPoints; i++ )
{
const double x = points[i].x() - dx;
const double y = points[i].y() - dy;
renderer->render( painter,
QRectF( x, y, sz.width(), sz.height() ) );
}
}
示例3: end
/*!
Expand the selected rectangle to minZoomSize() and zoom in
if accepted.
\sa accept(), minZoomSize()
*/
bool QwtPlotZoomer::end( bool ok )
{
ok = QwtPlotPicker::end( ok );
if ( !ok )
return false;
QwtPlot *plot = QwtPlotZoomer::plot();
if ( !plot )
return false;
const QPolygon &pa = selection();
if ( pa.count() < 2 )
return false;
QRect rect = QRect( pa[0], pa[int( pa.count() - 1 )] );
rect = rect.normalized();
QRectF zoomRect = invTransform( rect ).normalized();
const QSizeF minSize = minZoomSize();
if ( minSize.isValid() )
{
const QPointF center = zoomRect.center();
zoomRect.setSize( zoomRect.size().expandedTo( minZoomSize() ) );
zoomRect.moveCenter( center );
}
zoom( zoomRect );
return true;
}
示例4: load
bool ContentLoader::load( const QString& filename,
const QPointF& windowCenterPosition,
const QSizeF& windowSize )
{
put_flog( LOG_INFO, "opening: '%s'", filename.toLocal8Bit().constData( ));
ContentPtr content = ContentFactory::getContent( filename );
if( !content )
{
put_flog( LOG_WARN, "ignoring unsupported file: '%s'",
filename.toLocal8Bit().constData( ));
return false;
}
ContentWindowPtr contentWindow( new ContentWindow( content ));
ContentWindowController controller( *contentWindow, *displayGroup_ );
if( windowSize.isValid( ))
controller.resize( windowSize );
else
controller.adjustSize( SIZE_LARGE );
if( windowCenterPosition.isNull( ))
controller.moveCenterTo( displayGroup_->getCoordinates().center( ));
else
controller.moveCenterTo( windowCenterPosition );
displayGroup_->addContentWindow( contentWindow );
return true;
}
示例5: 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;
}
示例6: end
bool PlotZoomer::end(bool ok)
{
// Code here is taken from QwtPlotZoomer. The only modification is around the _zoomMode handling.
ok = QwtPlotPicker::end(ok);
if (!ok)
{
return false;
}
QwtPlot *plot = QwtPlotZoomer::plot();
if (!plot)
{
return false;
}
const QPolygon &pa = selection();
if (pa.count() < 2)
{
return false;
}
QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]);
rect = rect.normalized();
QRectF currentZoomRect = zoomRect();
QRectF zoomRect = invTransform(rect).normalized();
switch (_zoomMode)
{
default:
case ZoomBoth:
// nothing.
break;
case ZoomX:
// Maintain current zoom y and height.
zoomRect.setY(currentZoomRect.y());
zoomRect.setHeight(currentZoomRect.height());
break;
case ZoomY:
// Maintain current zoom x and width.
zoomRect.setX(currentZoomRect.x());
zoomRect.setWidth(currentZoomRect.width());
break;
}
const QSizeF minSize = minZoomSize();
if (minSize.isValid())
{
const QPointF center = zoomRect.center();
zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize()));
zoomRect.moveCenter(center);
}
zoom(zoomRect);
return true;
}
示例7: adjustBoxSize
void QgsComposerLegend::adjustBoxSize()
{
QSizeF size = paintAndDetermineSize( 0 );
if ( size.isValid() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), size.width(), size.height() ) );
}
}
示例8: updatePanner
void PhotoView::updatePanner( const QSizeF & vpSize )
{
QSizeF viewportSize = vpSize;
if ( ! viewportSize.isValid() )
viewportSize = size();
if ( viewportSize.width() < _panner->size().width() * 2 ||
viewportSize.height() < _panner->size().height() * 2 )
{
// If the panner would take up more than half the available space
// in any direction, don't show it.
_panner->hide();
}
else
{
Photo * photo = _photoDir->current();
if ( ! photo )
{
_panner->hide();
}
else
{
QSizeF origSize = photo->size();
QPointF canvasPos = _canvas->pos();
QSizeF canvasSize = _canvas->size();
qreal pannerX = 0.0;
qreal pannerY = -_panner->size().height();
if ( canvasSize.width() < viewportSize.width() )
pannerX = canvasPos.x();
if ( canvasSize.height() < viewportSize.height() )
pannerY += canvasPos.y() + canvasSize.height();
else
pannerY += viewportSize.height();
_panner->setPos( pannerX, pannerY );
QPointF visiblePos( -canvasPos.x(), -canvasPos.y() );
QSizeF visibleSize( qMin( viewportSize.width(),
canvasSize.width() ),
qMin( viewportSize.height(),
canvasSize.height() ) );
QRectF visibleRect( visiblePos / _zoomFactor,
visibleSize / _zoomFactor );
_panner->updatePanRect( visibleRect, origSize );
}
}
}
示例9: effectiveSizeHint
/*!
Returns the effective size hint for this QGraphicsLayoutItem.
\a which is the size hint in question.
\a constraint is an optional argument that defines a special constrain
when calculating the effective size hint. By default, \a constraint is
QSizeF(-1, -1), which means there is no constraint to the size hint.
If you want to specify the widget's size hint for a given width or height,
you can provide the fixed dimension in \a constraint. This is useful for
widgets that can grow only either vertically or horizontally, and need to
set either their width or their height to a special value.
For example, a text paragraph item fit into a column width of 200 may
grow vertically. You can pass QSizeF(200, -1) as a constraint to get a
suitable minimum, preferred and maximum height).
You can adjust the effective size hint by reimplementing sizeHint()
in a QGraphicsLayoutItem subclass, or by calling one of the following
functions: setMinimumSize(), setPreferredSize, or setMaximumSize()
(or a combination of both).
This function caches each of the size hints and guarantees that
sizeHint() will be called only once for each value of \a which - unless
\a constraint is not specified and updateGeometry() has been called.
\sa sizeHint()
*/
QSizeF QGraphicsLayoutItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_D(const QGraphicsLayoutItem);
if (!d->userSizeHints && constraint.isValid())
return constraint;
// ### should respect size policy???
return d_ptr->effectiveSizeHints(constraint)[which];
}
示例10: getMaxContentSize
QSizeF ContentWindowController::getMaxContentSize() const
{
QSizeF maxContentSize = _contentWindow->getContent()->getMaxDimensions();
if( maxContentSize.isValid( ))
return maxContentSize;
maxContentSize = _contentWindow->getContent()->getDimensions();
return maxContentSize.scaled( _displayGroup->getCoordinates().size(),
Qt::KeepAspectRatioByExpanding );
}
示例11: adjustBoxSize
void QgsComposerLegend::adjustBoxSize()
{
QgsLegendRenderer legendRenderer( &mLegendModel, mSettings );
QSizeF size = legendRenderer.minimumSize();
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( size.width() ).arg( size.height() ) );
if ( size.isValid() )
{
setSceneRect( QRectF( pos().x(), pos().y(), size.width(), size.height() ) );
}
}
示例12: sizeChanged
void Tagaro::SpriteObjectItem::setSize(const QSizeF& size)
{
if (d->m_size != size && size.isValid())
{
prepareGeometryChange();
d->m_size = size;
d->updateTransform();
emit sizeChanged(size);
update();
}
}
示例13: nativeSizeChanged
void MediaPlayerPrivateQt::nativeSizeChanged(const QSizeF& size)
{
LOG(Media, "MediaPlayerPrivateQt::naturalSizeChanged(%dx%d)",
size.toSize().width(), size.toSize().height());
if (!size.isValid())
return;
m_naturalSize = size.toSize();
m_webCorePlayer->sizeChanged();
}
示例14:
void QgsDiagramRendererV2::convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const
{
if ( !size.isValid() )
{
return;
}
double pixelToMap = context.scaleFactor() * context.mapToPixel().mapUnitsPerPixel();
size.rwidth() *= pixelToMap;
size.rheight() *= pixelToMap;
}
示例15: adjustBoxSize
void QgsComposerLegend::adjustBoxSize()
{
QgsLegendRenderer legendRenderer( mLegendModel2, mSettings );
QSizeF size = legendRenderer.minimumSize();
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( size.width() ).arg( size.height() ) );
if ( size.isValid() )
{
QRectF targetRect = QRectF( pos().x(), pos().y(), size.width(), size.height() );
//set new rect, respecting position mode and data defined size/position
setSceneRect( evalItemRect( targetRect, true ) );
}
}