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


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

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


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

示例1: size

QSizeF CanvasSize::size(SizeUnits unit) const
{
    QSizeF result;
    result.setWidth( toPixels(m_size.width(), m_resolution.width(), m_size_unit, m_resolution_unit) );
    result.setHeight( toPixels(m_size.height(), m_resolution.height(), m_size_unit, m_resolution_unit) );
    if (unit != Pixels)
    {
        result.setWidth( fromPixels(result.width(), m_resolution.width(), unit, m_resolution_unit) );
        result.setHeight( fromPixels(result.height(), m_resolution.height(), unit, m_resolution_unit) );
    }
    return result;
}
开发者ID:NathanDM,项目名称:kipi-plugins,代码行数:12,代码来源:CanvasSize.cpp

示例2: 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

示例3: targetSize

    QSizeF targetSize() const {
        QSizeF size = imageData->imageSize();
        if (targetImageSizePercent.width() > 0.0)
            size.setWidth(0.01 * targetImageSizePercent.width() * size.width());
        else if (targetImageSize.width() > 0.0)
            size.setWidth(targetImageSize.width());
        if (targetImageSizePercent.height() > 0.0)
            size.setHeight(0.01 * targetImageSizePercent.height() * size.height());
        else if (targetImageSize.height() > 0.0)
            size.setHeight(targetImageSize.height());

        return size;
    }
开发者ID:IGLOU-EU,项目名称:krita,代码行数:13,代码来源:KoPatternBackground.cpp

示例4: 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

示例5: minimumSizeHint

QSizeF UIGraphicsScrollArea::minimumSizeHint() const
{
    /* Minimum size-hint of scroll-bar by default: */
    QSizeF msh = m_pScrollBar->minimumSizeHint();
    if (m_pViewport)
    {
        switch (m_enmOrientation)
        {
            case Qt::Horizontal:
            {
                /* Expand it with viewport height: */
                const int iWidgetHeight = m_pViewport->size().height();
                if (msh.height() < iWidgetHeight)
                    msh.setHeight(iWidgetHeight);
                break;
            }
            case Qt::Vertical:
            {
                /* Expand it with viewport width: */
                const int iWidgetWidth = m_pViewport->size().width();
                if (msh.width() < iWidgetWidth)
                    msh.setWidth(iWidgetWidth);
                break;
            }
        }
    }
    return msh;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:28,代码来源:UIGraphicsScrollArea.cpp

示例6: applyViewboxTransformation

void KPathShapePrivate::applyViewboxTransformation(const KXmlElement &element)
{
    Q_Q(KPathShape);
    // apply viewbox transformation
    QRectF viewBox = q->loadOdfViewbox(element);
    if (! viewBox.isEmpty()) {
        // load the desired size
        QSizeF size;
        size.setWidth(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "width", QString())));
        size.setHeight(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "height", QString())));

        // load the desired position
        QPointF pos;
        pos.setX(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "x", QString())));
        pos.setY(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "y", QString())));

        // create matrix to transform original path data into desired size and position
        QTransform viewMatrix;
        viewMatrix.translate(-viewBox.left(), -viewBox.top());
        viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
        viewMatrix.translate(pos.x(), pos.y());

        // transform the path data
        map(viewMatrix);
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:26,代码来源:KPathShape.cpp

示例7: loadSizeF

/**
 * @brief cwRegionLoadTask::loadSizeF
 * @param protoSize
 * @return
 */
QSizeF cwRegionLoadTask::loadSizeF(const QtProto::QSizeF &protoSize)
{
    QSizeF size;
    size.setWidth(protoSize.width());
    size.setHeight(protoSize.height());
    return size;
}
开发者ID:Cavewhere,项目名称:cavewhere,代码行数:12,代码来源:cwRegionLoadTask.cpp

示例8: updateGeometry

/**
 * Reimplemented from UMLWidget::updateGeometry to calculate
 * minimum size for signal widget based on the current signal type.
 */
void SignalWidget::updateGeometry()
{
    QSizeF minSize = textItemGroupAt(GroupIndex)->minimumSize();
    if (minSize.width() < SignalWidget::MinimumSize.width()) {
        minSize.setWidth(SignalWidget::MinimumSize.width());
    }

    if (m_signalType == SignalWidget::Accept) {
        // We need 1/3rd part for the '>' shape.(hollow or convex)
        minSize.rwidth() += minSize.width() / 3 + margin();
    }
    else if (m_signalType == SignalWidget::Send) {
        // Add one third for the '>' shape.
        minSize.rwidth() += minSize.width() / 3 + margin();
    }
    else if (m_signalType == SignalWidget::Time) {
        // In case of SignalWidget::Time add minimum height to
        // calculated as the text appears below drawing.
        minSize.rheight() += SignalWidget::MinimumSize.height();
    }

    setMinimumSize(minSize);

    UMLWidget::updateGeometry();
}
开发者ID:jpleclerc,项目名称:Umbrello-ng2,代码行数:29,代码来源:signalwidget.cpp

示例9: createNewFolder

void RightClickStrategy::createNewFolder()
{
    FolderShape *fs = new FolderShape();
    // TODO show dialog to name the folder
    fs->setName("New folder");
    if (m_canvas->itemStore()->folders().count() == 1 && m_canvas->itemStore()->folders()[0]->border() == 0) {
        // the first new folder, lets be kinds and resize the folders to make it managable for the user.
        FolderShape *oldFolder = m_canvas->itemStore()->folders()[0];
        oldFolder->update();
        oldFolder->setBorder(new FolderBorder());
        KInsets insets = oldFolder->insets();
        oldFolder->setPosition(QPointF(insets.left, insets.top));
        QSizeF size = oldFolder->size(); // we can assume size is the size of the whole widget. So we just make each use half of that.
        size.setWidth(size.width() / 2.);
        oldFolder->setSize(size);
        if (oldFolder->model()->count()) {
            // Make sure we don't resize the folder to small for its contents.
            QPointF bottom = oldFolder->model()->shapes().last()->absolutePosition(KFlake::BottomRightCorner);
            if (bottom.y() > size.height())
                oldFolder->setSize(QSizeF(size.width(), bottom.y()));
        }
        oldFolder->update();

        fs->setPosition(QPointF(size.width(), insets.top));
        fs->setSize(size);
    } else {
        fs->setAbsolutePosition(m_lastPosition);
        fs->setSize(QSizeF(150, 100));
    }

    m_canvas->itemStore()->addFolder(fs);
}
开发者ID:KDE,项目名称:koffice,代码行数:32,代码来源:RightClickStrategy.cpp

示例10: doLayout

qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
{
    qreal left, top, right, bottom;
    getContentsMargins(&left, &top, &right, &bottom);
    const qreal maxw = geom.width() - left - right;

    qreal x = 0;
    qreal y = 0;
    qreal maxRowHeight = 0;
    QSizeF pref;
    for (int i = 0; i < m_items.count(); ++i) {
        QGraphicsLayoutItem *item = m_items.at(i);
        pref = item->effectiveSizeHint(Qt::PreferredSize);
        maxRowHeight = qMax(maxRowHeight, pref.height());

        qreal next_x;
        next_x = x + pref.width();
        if (next_x > maxw) {
            if (x == 0) {
                pref.setWidth(maxw);
            } else {
                x = 0;
                next_x = pref.width();
            }
            y += maxRowHeight + spacing(Qt::Vertical);
            maxRowHeight = 0;
        }

        if (applyNewGeometry)
            item->setGeometry(QRectF(QPointF(left + x, top + y), pref));
        x = next_x + spacing(Qt::Horizontal);
    }
    maxRowHeight = qMax(maxRowHeight, pref.height());
    return top + y + maxRowHeight + bottom;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:35,代码来源:flowlayout.cpp

示例11: expandSize

static void expandSize(QSizeF &result, const QSizeF &size)
{
    if (size.width() >= 0 && size.width() > result.width())
        result.setWidth(size.width());
    if (size.height() >= 0 && size.height() > result.height())
        result.setHeight(size.height());
}
开发者ID:husninazer,项目名称:qt,代码行数:7,代码来源:qgraphicslayoutitem.cpp

示例12: itemChange

// --------------------------------------------------------------------------------------------------------------------------------------
QVariant CSizeGrip::itemChange(GraphicsItemChange change, const QVariant &value)
{
    switch(change)
    {
    case QGraphicsItem::ItemPositionChange:
        {
            QPointF nextPos =  value.toPointF();
            QPointF targetPos = pos() - nextPos;
            QSizeF resultSize = gWindow()->size() - QSizeF(targetPos.x(), targetPos.y());

            if(resultSize.width() < gWindow()->minSize().width())
            {
                resultSize.setWidth(gWindow()->minSize().width());
                nextPos.setX(pos().x());
            }
            if(resultSize.height() < gWindow()->minSize().height())
            {
                resultSize.setHeight(gWindow()->minSize().height());
                nextPos.setY(pos().y());
            }
            gWindow()->setSize(resultSize);
            return nextPos;
        }
        break;
    default: return QGraphicsItem::itemChange(change, value);
    }
    return QGraphicsItem::itemChange(change, value);
}
开发者ID:Sheridan,项目名称:gpstool,代码行数:29,代码来源:csizegrip.cpp

示例13: combineSize

static void combineSize(QSizeF &result, const QSizeF &size)
{
    if (result.width() < 0)
        result.setWidth(size.width());
    if (result.height() < 0)
        result.setHeight(size.height());
}
开发者ID:arcean,项目名称:libmeegotouch-framework,代码行数:7,代码来源:mwidgetcontroller.cpp

示例14: readSize

QSizeF readSize(QDomElement e)
      {
      QSizeF p;
      p.setWidth(e.attribute("w", "0.0").toDouble());
      p.setHeight(e.attribute("h", "0.0").toDouble());
      return p;
      }
开发者ID:gthomas,项目名称:MuseScore,代码行数:7,代码来源:xml.cpp

示例15: _q_updateSize

void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged)
{
    Q_Q(QDeclarativeLoader);
    if (!item || updatingSize)
        return;

    updatingSize = true;
    if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
        if (!itemWidthValid)
            q->setImplicitWidth(qmlItem->implicitWidth());
        else
            q->setImplicitWidth(qmlItem->width());
        if (loaderGeometryChanged && q->widthValid())
            qmlItem->setWidth(q->width());
        if (!itemHeightValid)
            q->setImplicitHeight(qmlItem->implicitHeight());
        else
            q->setImplicitHeight(qmlItem->height());
        if (loaderGeometryChanged && q->heightValid())
            qmlItem->setHeight(q->height());
    } else if (item && item->isWidget()) {
        QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
        QSizeF widgetSize = widget->size();
        q->setImplicitWidth(widgetSize.width());
        if (loaderGeometryChanged && q->widthValid())
            widgetSize.setWidth(q->width());
        q->setImplicitHeight(widgetSize.height());
        if (loaderGeometryChanged && q->heightValid())
            widgetSize.setHeight(q->height());
        if (widget->size() != widgetSize)
            widget->resize(widgetSize);
    }
    updatingSize = false;
}
开发者ID:wpbest,项目名称:copperspice,代码行数:34,代码来源:qdeclarativeloader.cpp


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