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


C++ QVariant::toSizeF方法代码示例

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


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

示例1: setProperty

bool Image::setProperty(P_ID propertyId, const QVariant& v)
      {
      bool rv = true;
      score()->addRefresh(canvasBoundingRect());
      switch(propertyId) {
            case P_AUTOSCALE:
                  setAutoScale(v.toBool());
                  break;
            case P_SIZE:
                  setSize(v.toSizeF());
                  break;
            case P_SCALE:
                  setScale(v.toSizeF());
                  break;
            case P_LOCK_ASPECT_RATIO:
                  setLockAspectRatio(v.toBool());
                  break;
            case P_SIZE_IS_SPATIUM:
                  setSizeIsSpatium(v.toBool());
                  break;
            default:
                  rv = Element::setProperty(propertyId, v);
                  break;
            }
      setGenerated(false);
      score()->setLayoutAll(true);
      return rv;
      }
开发者ID:Jon0,项目名称:MuseScore,代码行数:28,代码来源:image.cpp

示例2: switch

void	LabelPrintEngine::setProperty ( PrintEnginePropertyKey key, const QVariant & value )
{
  switch(key) {
  case  QPrintEngine::PPK_PrinterName:
    m_printerName = value.toString();
    break;
  case  QPrintEngine::PPK_DocumentName:
    m_docName = value.toString();
    break;
  case  QPrintEngine::PPK_CustomPaperSize:
    m_paperSize = value.toSizeF();
    m_paperRect = QRect(QPoint(0,0),m_paperSize.toSize());
    break;
  case  QPrintEngine::PPK_PaperRect:
  case  QPrintEngine::PPK_PageRect:
    m_paperSize = value.toRect().size();
    m_paperRect = value.toRect();
    break;
  case  QPrintEngine::PPK_PageSize:
    // not implemented
    break;
  case  QPrintEngine::PPK_Resolution:
    m_resolution = value.toInt();
    break;
  default: break;
  }
}
开发者ID:ChristopherCotnoir,项目名称:openrpt,代码行数:27,代码来源:labelprintengine.cpp

示例3: isDefault

bool InspectorBase::isDefault(const InspectorItem& ii)
      {
      Element* e = inspector->element();
      for (int i = 0; i < ii.parent; ++i)
            e = e->parent();

      P_ID id      = ii.t;
      P_TYPE t     = propertyType(id);
      QVariant val = getValue(ii);
      QVariant def = e->propertyDefault(id);
      if (t == P_TYPE::SIZE || t == P_TYPE::SCALE || t == P_TYPE::SIZE_MM) {
            QSizeF sz = def.toSizeF();
            qreal v = ii.sv == 0 ? sz.width() : sz.height();
            return val.toDouble() == v;
            }
      if (t == P_TYPE::POINT || t == P_TYPE::POINT_MM) {
            QPointF sz = def.toPointF();
            qreal v = ii.sv == 0 ? sz.x() : sz.y();
            return val.toDouble() == v;
            }
      if (t == P_TYPE::FRACTION) {
            Fraction f = def.value<Fraction>();
            int v = ii.sv == 0 ? f.numerator() : f.denominator();
            return val.toInt() == v;
            }
      return val == def;
      }
开发者ID:FryderykChopin,项目名称:MuseScore,代码行数:27,代码来源:inspectorBase.cpp

示例4: setValue

void KSizeFComposedProperty::setValue(KProperty *property,
    const QVariant &value, bool rememberOldValue)
{
    const QSizeF s( value.toSizeF() );
    property->child("width")->setValue(s.width(), rememberOldValue, false);
    property->child("height")->setValue(s.height(), rememberOldValue, false);
}
开发者ID:KDE,项目名称:kproperty,代码行数:7,代码来源:sizefedit.cpp

示例5: setInformation

InformationName NodeInstance::setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation)
{
    switch (name) {
    case Size: return setInformationSize(information.toSizeF());
    case BoundingRect: return setInformationBoundingRect(information.toRectF());
    case ContentItemBoundingRect: return setInformationContentItemBoundingRect(information.toRectF());
    case Transform: return setInformationTransform(information.value<QTransform>());
    case ContentTransform: return setInformationContentTransform(information.value<QTransform>());
    case ContentItemTransform: return setInformationContentItemTransform(information.value<QTransform>());
    case PenWidth: return setInformationPenWith(information.toInt());
    case Position: return setInformationPosition(information.toPointF());
    case IsInLayoutable: return setInformationIsInLayoutable(information.toBool());
    case SceneTransform: return setInformationSceneTransform(information.value<QTransform>());
    case IsResizable: return setInformationIsResizable(information.toBool());
    case IsMovable: return setInformationIsMovable(information.toBool());
    case IsAnchoredByChildren: return setInformationIsAnchoredByChildren(information.toBool());
    case IsAnchoredBySibling: return setInformationIsAnchoredBySibling(information.toBool());
    case HasContent: return setInformationHasContent(information.toBool());
    case HasAnchor: return setInformationHasAnchor(information.toByteArray(), secondInformation.toBool());break;
    case Anchor: return setInformationAnchor(information.toByteArray(), secondInformation.toByteArray(), thirdInformation.value<qint32>());
    case InstanceTypeForProperty: return setInformationInstanceTypeForProperty(information.toByteArray(), secondInformation.toByteArray());
    case HasBindingForProperty: return setInformationHasBindingForProperty(information.toByteArray(), secondInformation.toBool());
    case NoName:
    default: break;
    }

    return NoInformationChange;
}
开发者ID:jay602,项目名称:QmlDesignerPlus,代码行数:28,代码来源:nodeinstance.cpp

示例6: setProperty

bool Image::setProperty(Pid propertyId, const QVariant& v)
      {
      bool rv = true;
      score()->addRefresh(canvasBoundingRect());
      switch(propertyId) {
            case Pid::AUTOSCALE:
                  setAutoScale(v.toBool());
                  break;
            case Pid::SIZE:
                  setSize(v.toSizeF());
                  break;
            case Pid::LOCK_ASPECT_RATIO:
                  setLockAspectRatio(v.toBool());
                  break;
            case Pid::SIZE_IS_SPATIUM:
                  {
                  QSizeF s = size2pixel(_size);
                  setSizeIsSpatium(v.toBool());
                  _size = pixel2size(s);
                  }
                  break;
            default:
                  rv = Element::setProperty(propertyId, v);
                  break;
            }
      setGenerated(false);
      _dirty = true;
      triggerLayout();
      return rv;
      }
开发者ID:IsaacWeiss,项目名称:MuseScore,代码行数:30,代码来源:image.cpp

示例7: start

void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, const QVariant& endValue)
{
    stop(widget, type);

    QPropertyAnimation* propertyAnim = nullptr;
    const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;

    switch (type) {
    case MovingAnimation: {
        const QPointF newPos = endValue.toPointF();
        if (newPos == widget->pos()) {
            return;
        }

        propertyAnim = new QPropertyAnimation(widget, "pos");
        propertyAnim->setDuration(animationDuration);
        propertyAnim->setEndValue(newPos);
        break;
    }

    case CreateAnimation: {
        propertyAnim = new QPropertyAnimation(widget, "opacity");
        propertyAnim->setEasingCurve(QEasingCurve::InQuart);
        propertyAnim->setDuration(animationDuration);
        propertyAnim->setStartValue(0.0);
        propertyAnim->setEndValue(1.0);
        break;
    }

    case DeleteAnimation: {
        propertyAnim = new QPropertyAnimation(widget, "opacity");
        propertyAnim->setEasingCurve(QEasingCurve::OutQuart);
        propertyAnim->setDuration(animationDuration);
        propertyAnim->setStartValue(1.0);
        propertyAnim->setEndValue(0.0);
        break;
    }

    case ResizeAnimation: {
        const QSizeF newSize = endValue.toSizeF();
        if (newSize == widget->size()) {
            return;
        }

        propertyAnim = new QPropertyAnimation(widget, "size");
        propertyAnim->setDuration(animationDuration);
        propertyAnim->setEndValue(newSize);
        break;
    }

    default:
        break;
    }

    Q_ASSERT(propertyAnim);
    connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished);
    m_animation[type].insert(widget, propertyAnim);

    propertyAnim->start();
}
开发者ID:stream009,项目名称:dolphin,代码行数:60,代码来源:kitemlistviewanimation.cpp

示例8: save

void XmlQSizeFSerializator::save(const QVariant &value, QString name)
{
    QSizeF size = value.toSizeF();
    QDomElement _node = doc()->createElement(name);
    _node.setAttribute("Type","QSizeF");
    _node.setAttribute("width",QString::number(size.width()));
    _node.setAttribute("height",QString::number(size.height()));
    node()->appendChild(_node);
}
开发者ID:BigLeb32,项目名称:diplomprog,代码行数:9,代码来源:lrxmlbasetypesserializators.cpp

示例9: applyMapObjectValue

void PropertyBrowser::applyMapObjectValue(PropertyId id, const QVariant &val)
{
    MapObject *mapObject = static_cast<MapObject*>(mObject);
    QUndoCommand *command = 0;

    switch (id) {
    case NameProperty:
    case TypeProperty:
        command = new ChangeMapObject(mMapDocument, mapObject,
                                      mIdToProperty[NameProperty]->value().toString(),
                                      mIdToProperty[TypeProperty]->value().toString());
        break;
    case VisibleProperty:
        command = new SetMapObjectVisible(mMapDocument, mapObject, val.toBool());
        break;
    case PositionProperty: {
        const QPointF oldPos = mapObject->position();
        mapObject->setPosition(val.toPointF());
        command = new MoveMapObject(mMapDocument, mapObject, oldPos);
        break;
    }
    case SizeProperty: {
        const QSizeF oldSize = mapObject->size();
        mapObject->setSize(val.toSizeF());
        command = new ResizeMapObject(mMapDocument, mapObject, oldSize);
        break;
    }
    case RotationProperty: {
        const qreal oldRotation = mapObject->rotation();
        mapObject->setRotation(val.toDouble());
        command = new RotateMapObject(mMapDocument, mapObject, oldRotation);
        break;
    }
    case FlippingProperty: {
        const int flippingFlags = val.toInt();
        const bool flippedHorizontally = flippingFlags & 1;
        const bool flippedVertically = flippingFlags & 2;

        // You can only change one checkbox at a time
        if (mapObject->cell().flippedHorizontally != flippedHorizontally) {
            command = new FlipMapObjects(mMapDocument,
                                         QList<MapObject*>() << mapObject,
                                         FlipHorizontally);
        } else if (mapObject->cell().flippedVertically != flippedVertically) {
            command = new FlipMapObjects(mMapDocument,
                                         QList<MapObject*>() << mapObject,
                                         FlipVertically);
        }
    }
    default:
        break;
    }

    if (command)
        mMapDocument->undoStack()->push(command);
}
开发者ID:josephbleau,项目名称:tiled,代码行数:56,代码来源:propertybrowser.cpp

示例10: write

QString write(const QVariant &variant)
{
    if (!variant.isValid()) {
        qWarning() << "Trying to serialize invalid QVariant";
        return QString();
    }
    QString value;
    switch (variant.type()) {
    case QMetaType::QPoint:
    {
        QPoint p = variant.toPoint();
        value = QString("%1,%2").arg(QString::number(p.x()), QString::number(p.y()));
        break;
    }
    case QMetaType::QPointF:
    {
        QPointF p = variant.toPointF();
        value = QString("%1,%2").arg(QString::number(p.x(), 'f'), QString::number(p.y(), 'f'));
        break;
    }
    case QMetaType::QSize:
    {
        QSize s = variant.toSize();
        value = QString("%1x%2").arg(QString::number(s.width()), QString::number(s.height()));
        break;
    }
    case QMetaType::QSizeF:
    {
        QSizeF s = variant.toSizeF();
        value = QString("%1x%2").arg(QString::number(s.width(), 'f'), QString::number(s.height(), 'f'));
        break;
    }
    case QMetaType::QRect:
    {
        QRect r = variant.toRect();
        value = QString("%1,%2,%3x%4").arg(QString::number(r.x()), QString::number(r.y()),
                                           QString::number(r.width()), QString::number(r.height()));
        break;
    }
    case QMetaType::QRectF:
    {
        QRectF r = variant.toRectF();
        value = QString("%1,%2,%3x%4").arg(QString::number(r.x(), 'f'), QString::number(r.y(), 'f'),
                                           QString::number(r.width(), 'f'), QString::number(r.height(), 'f'));
        break;
    }
    default:
        QVariant strVariant = variant;
        strVariant.convert(QVariant::String);
        if (!strVariant.isValid())
            qWarning() << Q_FUNC_INFO << "cannot serialize type " << QMetaType::typeName(variant.type());
        value = strVariant.toString();
    }

    return value;
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例11: WriteAttributes

static void WriteAttributes(QObject* obj,QDomElement& el,QDomDocument& doc) {
    el.setAttribute("type",obj->metaObject()->className());
    for(int i = 0; i < obj->metaObject()->propertyCount(); ++i) {
        QMetaProperty metaProperty(obj->metaObject()->property(i));
        {
            QDomElement prop = doc.createElement("property");
            prop.setAttribute("name",QString(metaProperty.name()));
            QVariant value = metaProperty.read(obj);
            QString strValue;
            if (metaProperty.type()==QVariant::String) {
                strValue = value.toString();
            } else if (metaProperty.type()==QVariant::Int) {
                strValue = value.toString();
            } else if (metaProperty.type()==QVariant::UInt) {
                strValue = value.toString();
            } else if (metaProperty.type()==QVariant::Double) {
                strValue = value.toString();
            } else if (metaProperty.type()==QVariant::Bool) {
                strValue = value.toBool() ? "1" : "0";
            } else if (metaProperty.type()==QVariant::Point) {
                strValue = QString::number(value.toPoint().x())+";"
                           + QString::number(value.toPoint().y());
            } else if (metaProperty.type()==QVariant::PointF) {
                strValue = QString::number(value.toPointF().x())+";"
                           + QString::number(value.toPointF().y());
            } else if (metaProperty.type()==QVariant::Size) {
                strValue = QString::number(value.toSize().width())+";"
                           + QString::number(value.toSize().height());
            } else if (metaProperty.type()==QVariant::SizeF) {
                strValue = QString::number(value.toSizeF().width())+";"
                           + QString::number(value.toSizeF().height());
            } else {
                QByteArray ar;
                QDataStream ds(&ar,QIODevice::WriteOnly);
                ds << value;
                strValue = ar.toBase64().data();
            }
            prop.setAttribute("value",strValue);
            el.appendChild(prop);
        }
    }
}
开发者ID:andryblack,项目名称:Chipmunk-Sandbox,代码行数:42,代码来源:scene.cpp

示例12: assert

void
CQPropertySizeFEditor::
setValue(QWidget *w, const QVariant &var)
{
  CQPoint2DEdit *edit = qobject_cast<CQPoint2DEdit *>(w);
  assert(edit);

  QSizeF s = var.toSizeF();

  edit->setValue(QPointF(s.width(), s.height()));
}
开发者ID:colinw7,项目名称:CQPropertyTree,代码行数:11,代码来源:CQPropertyEditor.cpp

示例13: valueToString

QString PropertyField::valueToString(QVariant val)
{
    QString text;
    switch (val.type()) {
    case QVariant::Double:
        text = QString("%1").arg(val.toReal(), 0, 'f', 4);
        break;
    case QVariant::Size:
        text = QString("%1 x %2").arg(val.toSize().width()).arg(val.toSize().height());
        break;
    case QVariant::SizeF:
        text = QString("%1 x %2").arg(val.toSizeF().width()).arg(val.toSizeF().height());
        break;
    case QVariant::Rect: {
        QRect rect = val.toRect();
        text = QString("%1 x %2 %3%4 %5%6").arg(rect.width())
                .arg(rect.height()).arg(rect.x() < 0 ? "" : "+").arg(rect.x())
                .arg(rect.y() < 0 ? "" : "+").arg(rect.y());
        } break;
    default:
        text = val.toString();
    }
    return text;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:24,代码来源:propertyfield.cpp

示例14: valueToString

QString KPropertySizeFDelegate::valueToString(const QVariant& value, const QLocale &locale) const
{
    const QSizeF s(value.toSizeF());
    if (s.isNull()) {
        if (locale.language() == QLocale::C) {
            return QString();
        }
        return QObject::tr("None", "Null value");
    }
    if (locale.language() == QLocale::C) {
        return QString::fromLatin1("%1x%2").arg(s.width()).arg(s.height());
    }
    return QObject::tr("%1x%2", "Size")
        .arg(locale.toString(s.width()))
        .arg(locale.toString(s.height()));
}
开发者ID:KDE,项目名称:kproperty,代码行数:16,代码来源:sizefedit.cpp

示例15: setProperty

bool Lasso::setProperty(P_ID propertyId, const QVariant& v)
{
    switch(propertyId) {
    case P_ID::LASSO_POS:
        _rect.moveTo(v.toPointF());
        break;
    case P_ID::LASSO_SIZE:
        _rect.setSize(v.toSizeF());
        break;
    default:
        if (!Element::setProperty(propertyId, v))
            return false;
        break;
    }
    score()->setUpdateAll();
    return true;
}
开发者ID:curiousbadger,项目名称:MuseScore,代码行数:17,代码来源:lasso.cpp


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