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


C++ QSizeF::isEmpty方法代码示例

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


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

示例1: setSceneRect

void QgsComposerPicture::setSceneRect( const QRectF& rectangle )
{

  QSizeF currentPictureSize = pictureSize();

  if ( mResizeMode == QgsComposerPicture::Clip )
  {
    QgsComposerItem::setSceneRect( rectangle );
    mPictureWidth = rectangle.width();
    mPictureHeight = rectangle.height();
    return;
  }

  QRectF newRect = rectangle;

  if ( mResizeMode == ZoomResizeFrame && !rect().isEmpty() && !( currentPictureSize.isEmpty() ) )
  {
    //if width has changed less than height, then fix width and set height correspondingly
    //else, do the opposite
    if ( qAbs( rect().width() - rectangle.width() ) <
         qAbs( rect().height() - rectangle.height() ) )
    {
      newRect.setHeight( currentPictureSize.height() * newRect.width() / currentPictureSize.width() );
    }
    else
    {
      newRect.setWidth( currentPictureSize.width() * newRect.height() / currentPictureSize.height() );
    }
  }
  else if ( mResizeMode == FrameToImageSize )
  {
    if ( !( currentPictureSize.isEmpty() ) )
    {
      newRect.setWidth( currentPictureSize.width() * 25.4 / mComposition->printResolution() );
      newRect.setHeight( currentPictureSize.height() * 25.4 / mComposition->printResolution() );
    }
  }

  //find largest scaling of picture with this rotation which fits in item
  if ( mResizeMode == Zoom )
  {
    QRectF rotatedImageRect = largestRotatedRectWithinBounds( QRectF( 0, 0, currentPictureSize.width(), currentPictureSize.height() ), newRect, mPictureRotation );
    mPictureWidth = rotatedImageRect.width();
    mPictureHeight = rotatedImageRect.height();
  }
  else
  {
    mPictureWidth = newRect.width();
    mPictureHeight = newRect.height();
  }

  QgsComposerItem::setSceneRect( newRect );
  emit itemChanged();
}
开发者ID:Asjad27,项目名称:QGIS,代码行数:54,代码来源:qgscomposerpicture.cpp

示例2: setExactSizeProject

void CanvasAppliance::setExactSizeProject(bool usePrevious)
{
    ui.projectCombo->setCurrentIndex(1);
    m_extCanvas->clearMarkers();
    if (!usePrevious || !m_extCanvas->modeInfo()->fixedSize()) {
        ExactSizeDialog sizeDialog;
        QSizeF prevSizeInches = m_extCanvas->modeInfo()->fixedSizeInches();
        if (!prevSizeInches.isEmpty()) {
            bool cm = !sizeDialog.ui.unityComboBox->currentIndex();
            sizeDialog.ui.widthSpinBox->setValue(cm?prevSizeInches.width()*2.54:prevSizeInches.width());
            sizeDialog.ui.heightSpinBox->setValue(cm?prevSizeInches.height()*2.54:prevSizeInches.height());
        }
        QPointF screenDpi = m_extCanvas->modeInfo()->screenDpi();
        if (screenDpi.x() == screenDpi.y())
            sizeDialog.ui.screenDpi->setValue((int)screenDpi.x());
        else
            sizeDialog.ui.screenDpi->setSpecialValueText(QString("%1, %2").arg(screenDpi.x()).arg(screenDpi.y()));
        if (sizeDialog.exec() != QDialog::Accepted)
            return;
        float w = sizeDialog.ui.widthSpinBox->value();
        float h = sizeDialog.ui.heightSpinBox->value();
        int printDpi = sizeDialog.ui.printDpi->value();
        bool landscape = sizeDialog.ui.landscapeCheckBox->isChecked();
        bool cm = !sizeDialog.ui.unityComboBox->currentIndex();
        m_extCanvas->modeInfo()->setPrintLandscape(landscape);
        m_extCanvas->modeInfo()->setPrintDpi(printDpi);
        m_extCanvas->modeInfo()->setFixedSizeInches(QSizeF(cm?(double)w/2.54:w, cm?(double)h/2.54:h));
    }
    m_extCanvas->modeInfo()->setProjectMode(CanvasModeInfo::ModeExactSize);
    m_extCanvas->adjustSceneSize();
    configurePrint(true);
}
开发者ID:enricoros,项目名称:fotowall,代码行数:32,代码来源:CanvasAppliance.cpp

示例3: stretch

QFont Font::stretch(const QFont& baseFont, int rows, int cols, const QSizeF& size)
{
    Q_ASSERT(rows > 0);
    Q_ASSERT(cols > 0);
    Q_ASSERT(!size.isEmpty());

    int height = size.height() / rows;

    // Create the font
    QFont font(baseFont);
    // Set the size
    font.setPixelSize(height);

    // Get the actual metrics of the font
    QFontMetrics metrics(font);

    // Is the font height greater than requested?
    if (metrics.height() > height)
    {
	// Recreate the font
	int diff = metrics.height() - height;
	font.setPixelSize(height - diff);

	metrics = QFontMetrics(font);
	while (metrics.height() * rows > size.height())
	{
	    font.setPixelSize(font.pixelSize() - 1);
	    metrics = QFontMetrics(font);
	}
    }

    metrics = QFontMetrics(font);
    Q_ASSERT(metrics.height() * rows <= size.height());

    // Is the font too wide?
    int fontWidth = metrics.averageCharWidth();

    // Ideal width
    int width = size.width() / cols;
    if (width > 0)
    {
	int newWidth = (width * 100) / fontWidth;
	font.setStretch(newWidth);

	// Anything left over?
	metrics = QFontMetrics(font);
	if (metrics.averageCharWidth() * cols < size.width())
	{
	    qreal diff = size.width() - (metrics.averageCharWidth() * cols);
	    diff /= cols;
	    font.setLetterSpacing(QFont::AbsoluteSpacing, diff);
	}
    }

    return font;
}
开发者ID:robcaldecott,项目名称:jupiter,代码行数:56,代码来源:Font.cpp

示例4: logicalDpi

QDpi QEGLDeviceIntegration::logicalDpi() const
{
    const QSizeF ps = physicalScreenSize();
    const QSize s = screenSize();

    if (!ps.isEmpty() && !s.isEmpty())
        return QDpi(25.4 * s.width() / ps.width(),
                    25.4 * s.height() / ps.height());
    else
        return QDpi(100, 100);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:11,代码来源:qeglfsdeviceintegration.cpp

示例5: setRegionOfInterest

void QtCamRoi::setRegionOfInterest(const QRectF& roi) {
  if (!d_ptr->dev || !d_ptr->dev->viewfinder()) {
    return;
  }

  QSizeF vf = d_ptr->dev->viewfinder()->videoResolution();
  if (vf.isEmpty()) {
    return;
  }

  int frameWidth = vf.width();
  int frameHeight = vf.height();
  int x = roi.x() * frameWidth;
  int y = roi.y() * frameHeight;
  int width = roi.width() * frameWidth;
  int height = roi.height() * frameHeight;

  // if we have an empty roi then we reset:
  int priority = roi.isEmpty() ? 0 : 1;

  GstStructure *region = gst_structure_new("region0",
					   "region-x", G_TYPE_UINT, x,
					   "region-y", G_TYPE_UINT, y,
					   "region-w", G_TYPE_UINT, width,
					   "region-h", G_TYPE_UINT, height,
					   "region-priority", G_TYPE_UINT, priority,
					   "region-id", G_TYPE_UINT, 0,
					   NULL);

  GValue regionValue = G_VALUE_INIT;
  GValue regionList = G_VALUE_INIT;

  g_value_init(&regionValue, GST_TYPE_STRUCTURE);
  g_value_init(&regionList, GST_TYPE_LIST);

  gst_value_set_structure(&regionValue, region);
  gst_value_list_append_value(&regionList, &regionValue);

  GstStructure *s = gst_structure_new("regions-of-interest",
				      "frame-width", G_TYPE_UINT, frameWidth,
				      "frame-height", G_TYPE_UINT, frameHeight,
				      NULL);
  gst_structure_set_value(s, "regions", &regionList);

  GstEvent *event = gst_event_new_custom(GST_EVENT_CUSTOM_UPSTREAM, s);
  gst_structure_free(region);
  g_value_unset(&regionValue);
  g_value_unset(&regionList);

  if (!d_ptr->sendEventToSource(event)) {
    qWarning() << "Failed to send ROI event";
  }
}
开发者ID:ballock,项目名称:cameraplus,代码行数:53,代码来源:qtcamroi.cpp

示例6: physicalScreenSizeFromFb

QSizeF EglUtils::physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize)
{
#ifndef Q_OS_LINUX
    Q_UNUSED(framebufferDevice)
#endif
    const int defaultPhysicalDpi = 100;
    static QSizeF size;

    if (size.isEmpty()) {
        // Note: in millimeters
        int width = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_WIDTH");
        int height = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_HEIGHT");

        if (width && height) {
            size.setWidth(width);
            size.setHeight(height);
            return size;
        }

        int w = -1;
        int h = -1;
        QSize screenResolution;
#ifdef Q_OS_LINUX
        struct fb_var_screeninfo vinfo;

        if (framebufferDevice != -1) {
            if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) {
                qCWarning(lcEglConvenience, "Could not query screen info");
            } else {
                w = vinfo.width;
                h = vinfo.height;
                screenResolution = QSize(vinfo.xres, vinfo.yres);
            }
        } else
#endif
        {
            // Use the provided screen size, when available, since some platforms may have their own
            // specific way to query it. Otherwise try querying it from the framebuffer.
            screenResolution = screenSize.isEmpty() ? screenSizeFromFb(framebufferDevice) : screenSize;
        }

        size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
        size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));

        if (w <= 0 || h <= 0)
            qCWarning(lcEglConvenience,
                      "Unable to query physical screen size, defaulting to %d dpi.\n"
                      "To override, set GREENISLAND_QPA_PHYSICAL_WIDTH "
                      "and GREENISLAND_QPA_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi);
    }

    return size;
}
开发者ID:comicfans,项目名称:greenisland,代码行数:53,代码来源:eglconvenience.cpp

示例7: legendIcon

/*!
  \return Icon for the legend

  In case of Tube style() the icon is a plain rectangle filled with the brush().
  If a symbol is assigned it is scaled to size.

  \param index Index of the legend entry 
               ( ignored as there is only one )
  \param size Icon size
    
  \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotIntervalCurve::legendIcon( 
    int index, const QSizeF &size ) const
{
    Q_UNUSED( index );

    if ( size.isEmpty() )
        return QwtGraphic();

    QwtGraphic icon;
    icon.setDefaultSize( size );
    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &icon );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    if ( d_data->style == Tube )
    {
        QRectF r( 0, 0, size.width(), size.height() );
        painter.fillRect( r, d_data->brush );
    }

    if ( d_data->symbol &&
        ( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) )
    {
        QPen pen = d_data->symbol->pen();
        pen.setWidthF( pen.widthF() );
        pen.setCapStyle( Qt::FlatCap );

        painter.setPen( pen );
        painter.setBrush( d_data->symbol->brush() );

        if ( orientation() == Qt::Vertical )
        {
            const double x = 0.5 * size.width();

            d_data->symbol->draw( &painter, orientation(),
                QPointF( x, 0 ), QPointF( x, size.height() - 1.0 ) );
        }
        else
        {
            const double y = 0.5 * size.height();

            d_data->symbol->draw( &painter, orientation(),
                QPointF( 0.0, y ), QPointF( size.width() - 1.0, y ) );
        }
    }

    return icon;
}
开发者ID:iclosure,项目名称:jdataanalyse,代码行数:62,代码来源:qwt_plot_intervalcurve.cpp

示例8: physicalScreenSize

QSizeF QEglFSHooks::physicalScreenSize() const
{
    static QSizeF size;
    if (size.isEmpty()) {

        // Note: in millimeters
        int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
        int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();

        if (width && height) {
            // no need to read fb0
            size.setWidth(width);
            size.setHeight(height);
            return size;
        }

        struct fb_var_screeninfo vinfo;
        int w = -1;
        int h = -1;

        if (framebuffer != -1) {
            if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
                qWarning("EGLFS: Could not query variable screen info.");
            } else {
                w = vinfo.width;
                h = vinfo.height;
            }
        }

        const int defaultPhysicalDpi = 100;
        size.setWidth(w <= 0 ? vinfo.xres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
        size.setHeight(h <= 0 ? vinfo.yres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));

        if (w <= 0 || h <= 0) {
            qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
                     "EGLFS: To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH "
                     "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).",
                     defaultPhysicalDpi);
        }

        // override fb0 from environment var setting
        if (width)
            size.setWidth(width);
        if (height)
            size.setWidth(height);
    }
    return size;
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:48,代码来源:qeglfshooks_stub.cpp

示例9: legendIcon

/*!
   \return Icon representing the marker on the legend

   \param index Index of the legend entry 
                ( usually there is only one )
   \param size Icon size

   \sa setLegendIconSize(), legendData()
*/
QwtGraphic QwtPlotMarker::legendIcon( int index,
    const QSizeF &size ) const
{
    Q_UNUSED( index );

    if ( size.isEmpty() )
        return QwtGraphic();

    QwtGraphic icon;
    icon.setDefaultSize( size );
    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &icon );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    if ( d_data->style != QwtPlotMarker::NoLine )
    {
        painter.setPen( d_data->pen );

        if ( d_data->style == QwtPlotMarker::HLine ||
            d_data->style == QwtPlotMarker::Cross )
        {
            const double y = 0.5 * size.height();

            QwtPainter::drawLine( &painter, 
                0.0, y, size.width(), y );
        }

        if ( d_data->style == QwtPlotMarker::VLine ||
            d_data->style == QwtPlotMarker::Cross )
        {
            const double x = 0.5 * size.width();

            QwtPainter::drawLine( &painter, 
                x, 0.0, x, size.height() );
        }
    }

    if ( d_data->symbol )
    {
        const QRect r( 0.0, 0.0, size.width(), size.height() );
        d_data->symbol->drawSymbol( &painter, r );
    }

    return icon;
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:56,代码来源:qwt_plot_marker.cpp

示例10: updateRects

void QGraphicsVideoItemPrivate::updateRects()
{
    q_ptr->prepareGeometryChange();
    QSizeF videoSize;
    if (nativeSize.isEmpty()) {
        videoSize = rect.size();
    } else if (aspectRatioMode == Qt::IgnoreAspectRatio) {
        videoSize = rect.size();
    } else {
        // KeepAspectRatio or KeepAspectRatioByExpanding
        videoSize = nativeSize;
        videoSize.scale(rect.size(), aspectRatioMode);
    }
    displayRect = QRectF(QPointF(0, 0), videoSize);
    displayRect.moveCenter(rect.center());
    boundingRect = displayRect.intersected(rect);
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:17,代码来源:qgraphicsvideoitem_overlay.cpp

示例11: setContentSize

void LabelGraphicsItem::setContentSize( const QSizeF &contentSize )
{
    QSizeF updatedSize = contentSize;
    if ( updatedSize.isEmpty() ) {
        updatedSize.setHeight( 0 );
        updatedSize.setWidth( 0 );
    }
    else {
        if ( d->m_minimumSize.width() > updatedSize.width() ) {
            updatedSize.setWidth( d->m_minimumSize.width() );
        }
        if ( d->m_minimumSize.height() > updatedSize.height() ) {
            updatedSize.setHeight( d->m_minimumSize.height() );
        }
    }

    FrameGraphicsItem::setContentSize( updatedSize );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:18,代码来源:LabelGraphicsItem.cpp

示例12: qwtScaledBoundingRect

static inline QRectF qwtScaledBoundingRect( 
    const QwtGraphic &graphic, const QSizeF size )
{
    QSizeF scaledSize = size;
    if ( scaledSize.isEmpty() )
        scaledSize = graphic.defaultSize();
        
    const QSizeF sz = graphic.controlPointRect().size();

    double sx = 1.0;
    if ( sz.width() > 0.0 )
        sx = scaledSize.width() / sz.width();
    
    double sy = 1.0;
    if ( sz.height() > 0.0 )
        sy = scaledSize.height() / sz.height();

    return graphic.scaledBoundingRect( sx, sy );
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:19,代码来源:qwt_symbol.cpp

示例13: QwtGraphic

QwtGraphic Plot2DProfile::legendIcon( int /*index*/, const QSizeF& iconSize ) const {
    if ( iconSize.isEmpty() ){
        return QwtGraphic();
    }
    QwtGraphic icon;
    icon.setDefaultSize( iconSize );
    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &icon );
    QPen pen( m_defaultColor );
    pen.setStyle( m_penStyle );
    pen.setWidth( 3 );
    const double y = 0.5 * iconSize.height();
    QPainterPath path;
    path.moveTo( 0.0, y );
    path.lineTo( iconSize.width(), y );
    painter.strokePath( path, pen );
    return icon;
}
开发者ID:Astroua,项目名称:CARTAvis,代码行数:19,代码来源:Plot2DProfile.cpp

示例14: legendIcon

/*!
  \return A rectangle filled with the color of the brush ( or the pen )

  \param index Index of the legend entry 
                ( usually there is only one )
  \param size Icon size

  \sa setLegendIconSize(), legendData()
*/
QwtGraphic QwtPlotShapeItem::legendIcon( int index,
    const QSizeF &size ) const
{
    Q_UNUSED( index );

    QwtGraphic icon;
    icon.setDefaultSize( size );

    if ( size.isEmpty() )
        return icon;

    if ( d_data->legendMode == QwtPlotShapeItem::LegendShape )
    {
        const QRectF &br = d_data->boundingRect;

        QPainter painter( &icon );
        painter.setRenderHint( QPainter::Antialiasing,
            testRenderHint( QwtPlotItem::RenderAntialiased ) );

        painter.translate( -br.topLeft() );

        painter.setPen( d_data->pen );
        painter.setBrush( d_data->brush );
        painter.drawPath( d_data->shape );
    }
    else
    {
        QColor iconColor;
        if ( d_data->brush.style() != Qt::NoBrush )
            iconColor = d_data->brush.color();
        else
            iconColor = d_data->pen.color();

        icon = defaultIcon( iconColor, size );
    }

    return icon;
}
开发者ID:OpenModelica,项目名称:OMPlot,代码行数:47,代码来源:qwt_plot_shapeitem.cpp

示例15: 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;
}
开发者ID:iclosure,项目名称:jdataanalyse,代码行数:76,代码来源:qwt_plot_curve.cpp


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