本文整理汇总了C++中QVariant::toRectF方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toRectF方法的具体用法?C++ QVariant::toRectF怎么用?C++ QVariant::toRectF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toRectF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: lessThan
bool ImageSortSettings::lessThan(const QVariant& left, const QVariant& right) const
{
if (left.type() != right.type())
{
return false;
}
switch (left.type())
{
case QVariant::Int:
return compareByOrder(left.toInt(), right.toInt(), currentSortOrder);
case QVariant::UInt:
return compareByOrder(left.toUInt(), right.toUInt(), currentSortOrder);
case QVariant::LongLong:
return compareByOrder(left.toLongLong(), right.toLongLong(), currentSortOrder);
case QVariant::ULongLong:
return compareByOrder(left.toULongLong(), right.toULongLong(), currentSortOrder);
case QVariant::Double:
return compareByOrder(left.toDouble(), right.toDouble(), currentSortOrder);
case QVariant::Date:
return compareByOrder(left.toDate(), right.toDate(), currentSortOrder);
case QVariant::DateTime:
return compareByOrder(left.toDateTime(), right.toDateTime(), currentSortOrder);
case QVariant::Time:
return compareByOrder(left.toTime(), right.toTime(), currentSortOrder);
case QVariant::Rect:
case QVariant::RectF:
{
QRectF rectLeft = left.toRectF();
QRectF rectRight = right.toRectF();
int result;
if ((result = compareByOrder(rectLeft.top(), rectRight.top(), currentSortOrder)) != 0)
{
return result < 0;
}
if ((result = compareByOrder(rectLeft.left(), rectRight.left(), currentSortOrder)) != 0)
{
return result < 0;
}
QSizeF sizeLeft = rectLeft.size(), sizeRight = rectRight.size();
if ((result = compareByOrder(sizeLeft.width()*sizeLeft.height(), sizeRight.width()*sizeRight.height(), currentSortOrder)) != 0)
{
return result < 0;
}
// FIXME: fall through?? If not, add "break" here
}
default:
return naturalCompare(left.toString(), right.toString(), currentSortOrder, sortCaseSensitivity);
}
}
示例3: inputMethodQuery
/*!
\internal
Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
reimplementation QGraphicsProxyWidget::inputMethodQuery().
*/
QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
{
Q_Q(const QGraphicsProxyWidget);
if (!widget || !q->hasFocus())
return QVariant();
QWidget *focusWidget = widget->focusWidget();
if (!focusWidget)
focusWidget = widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
switch (v.type()) {
case QVariant::RectF:
v = v.toRectF().translated(focusWidgetPos);
break;
case QVariant::PointF:
v = v.toPointF() + focusWidgetPos;
break;
case QVariant::Rect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
case QVariant::Point:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
break;
}
return v;
}
示例4: _q_checkMicroFocusHint
void MDeclarativeScreenPrivate::_q_checkMicroFocusHint()
{
if (!sipVisible)
return;
if (QWidget *widget = QApplication::focusWidget()) {
QVariant v = widget->inputMethodQuery(Qt::ImMicroFocus);
if (!v.toRectF().isValid())
return;
QRectF mf = v.toRectF();
if (mf != microFocus) {
microFocus = mf;
fprintf(stderr, "microfocus changed %f %f %f/%f\n", mf.x(), mf.y(), mf.width(), mf.height());
emit q->microFocusChanged();
}
}
}
示例5: 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;
}
示例6: scaleAnimationValueChanged
void QtViewportHandler::scaleAnimationValueChanged(QVariant value)
{
// Resetting the end value, the easing curve or the duration of the scale animation
// triggers a recalculation of the animation interval. This might change the current
// value of the animated property.
// Make sure we only act on animation value changes if the animation is active.
if (!scaleAnimationActive())
return;
setPageItemRectVisible(value.toRectF());
}
示例7: QRectF
QRectF
IrcAbstractChannel::cookedBoundingRect () const
{
if (qmlItem) {
QVariant rectVar;
QMetaObject::invokeMethod (qmlItem, "cookedBoundingRect",
Q_RETURN_ARG (QVariant, rectVar));
QRectF br = rectVar.toRectF();
return br;
}
return QRectF ();
}
示例8: changeProperty
bool QAbstractDiagramGraphicsItem::changeProperty(const QString & name, const QVariant & value)
{
QDiagramMetaProperty metaProperty = m_metadata->property(m_metadata->indexOfProperty(name));
// Check if property is dynamic
if (!metaProperty.isValid()){
// Check if dynamic property has changed
if (m_dynamicProperties.value(name) != value){
m_dynamicProperties[name] = value;
itemPropertyHasChanged(name, value);
}
return false;
}
// Check if static property is read only
if (metaProperty.isReadOnly()){
// Property is read only
return false;
}
QVariant currentValue = m_properties.value(name);
if (currentValue != value){
if (name == "brush"){
m_brush = brush(value.toString());
} else if (name == "geometry"){
if (value.canConvert(QVariant::RectF)){
prepareGeometryChange();
setPos(value.toRectF().x(), value.toRectF().y());
} else if (value.canConvert(QVariant::Map)){
prepareGeometryChange();
setPos(value.toMap().value("x").toDouble(), value.toMap().value("y").toDouble());
}
m_properties[name] = value;
itemGeometryHasChanged(value);
} else {
m_properties[name] = value;
}
itemPropertyHasChanged(name, value);
}
return true;
}
示例9:
void PageViewportControllerClientQt::ScaleAnimation::updateCurrentValue(const QVariant& value)
{
// Resetting the end value, the easing curve or the duration of the scale animation
// triggers a recalculation of the animation interval. This might change the current
// value of the animated property.
// Make sure we only act on animation value changes if the animation is active.
if (!m_controllerClient->scaleAnimationActive())
return;
QRectF itemRect = value.toRectF();
float itemScale = m_controllerClient->viewportScaleForRect(itemRect);
m_controllerClient->setContentRectVisiblePositionAtScale(itemRect.topLeft(), itemScale);
}
示例10: setVariant
int Slot::setVariant( PyrSlot *slot, const QVariant &val )
{
bool b_val;
int type = val.userType();
switch( type ) {
case QMetaType::Bool:
b_val = val.toBool();
if( b_val ) SetTrue( slot );
else SetFalse( slot );
return errNone;
case QMetaType::QPoint:
case QMetaType::QPointF:
return Slot::setPoint( slot, val.toPointF() );
case QMetaType::QRect:
case QMetaType::QRectF:
return Slot::setRect( slot, val.toRectF() );
case QMetaType::QString:
Slot::setString( slot, val.toString() );
return errNone;
case QMetaType::QColor:
return Slot::setColor( slot, val.value<QColor>() );
case QMetaType::QPalette:
return Slot::setPalette( slot, val.value<QPalette>() );
case QMetaType::Float:
case QMetaType::Double:
SetFloat( slot, val.value<float>() );
return errNone;
case QMetaType::Int:
SetInt( slot, val.toInt() );
return errNone;
case QMetaType::Void:
SetNil( slot );
return errNone;
default:
if( type == qMetaTypeId<VariantList>() ) {
Slot::setVariantList( slot, val.value<VariantList>() );
}
else {
qcErrorMsg( "the QVariant could not be interpreted!" );
return errFailed;
}
return errNone;
}
}
示例11: switch
//.........这里部分代码省略.........
output.SetArray();
output.Reserve(2, allocator);
output.PushBack(pt.width(), allocator);
output.PushBack(pt.height(), allocator);
break;
}
case QVariant::SizeF:
{
QSizeF pt = input.toSizeF();
output.SetArray();
output.Reserve(2, allocator);
output.PushBack(pt.width(), allocator);
output.PushBack(pt.height(), allocator);
break;
}
case QVariant::Rect:
{
QRect pt = input.toRect();
output.SetArray();
output.Reserve(4, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
output.PushBack(pt.width(), allocator);
output.PushBack(pt.height(), allocator);
break;
}
case QVariant::RectF:
{
QRectF pt = input.toRectF();
output.SetArray();
output.Reserve(4, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
output.PushBack(pt.width(), allocator);
output.PushBack(pt.height(), allocator);
break;
}
case QVariant::Vector2D:
{
QVector2D pt = input.value<QVector2D>();
output.SetArray();
output.Reserve(2, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
break;
}
case QVariant::Vector3D:
{
QVector3D pt = input.value<QVector3D>();
output.SetArray();
output.Reserve(3, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
output.PushBack(pt.z(), allocator);
break;
示例12: QString
//.........这里部分代码省略.........
ds << (quint32)value.toUInt();
else
ds << (quint64)value.toUInt();
break;
case QVariant::String:
ds << typeName;
ds << value.toString();
break;
case QVariant::Pixmap:
ds << typeName;
ds << value.value<QPixmap>();
break;
case QVariant::ByteArray:
ds << typeName;
ds << value.toByteArray();
break;
case QVariant::BitArray:
ds << typeName;
ds << value.toBitArray();
break;
case QVariant::Image:
ds << typeName;
ds << value.value<QImage>();
break;
case QVariant::Url:
ds << typeName;
ds << value.toUrl();
break;
case QVariant::StringList:
ds << typeName;
ds << value.toStringList();
break;
case QVariant::SizePolicy:
ds << typeName;
ds << value.value<QSizePolicy>();
break;
case QVariant::SizeF:
ds << typeName;
ds << value.toSizeF();
break;
case QVariant::Size:
ds << typeName;
ds << value.toSize();
break;
case QVariant::RegExp:
ds << typeName;
ds << value.toRegExp();
break;
case QVariant::RectF:
ds << typeName;
ds << value.toRectF();
break;
case QVariant::Rect:
ds << typeName;
ds << value.toRect();
break;
case QVariant::Polygon:
ds << typeName;
ds << value.value<QPolygon>();
break;
case QVariant::PointF:
ds << typeName;
ds << value.toPointF();
break;
case QVariant::Point:
ds << typeName;
ds << value.toPoint();
break;
case QVariant::Matrix:
ds << typeName;
ds << value.value<QMatrix>();
break;
case QVariant::LineF:
ds << typeName;
ds << value.toLineF();
break;
case QVariant::Line:
ds << typeName;
ds << value.toLine();
break;
case QVariant::Brush:
ds << typeName;
ds << value.value<QBrush>();
break;
case QVariant::Bitmap:
ds << typeName;
ds << value.value<QBitmap>();
break;
case QVariant::Transform:
ds << typeName;
ds << value.value<QTransform>();
break;
default:
// Other types will be supported shortly.
// TODO: support user defined types.
return false;
}
return true;
}
示例13: setVariant
int Slot::setVariant( PyrSlot *slot, const QVariant &val )
{
bool b_val;
int type = val.userType();
switch( type ) {
case QMetaType::Bool:
b_val = val.toBool();
if( b_val ) SetTrue( slot );
else SetFalse( slot );
return errNone;
case QMetaType::QPoint:
case QMetaType::QPointF:
return Slot::setPoint( slot, val.toPointF() );
case QMetaType::QSize:
case QMetaType::QSizeF:
Slot::setSize( slot, val.toSizeF() );
return errNone;
case QMetaType::QRect:
case QMetaType::QRectF:
return Slot::setRect( slot, val.toRectF() );
case QMetaType::QString:
Slot::setString( slot, val.toString() );
return errNone;
case QMetaType::QColor:
return Slot::setColor( slot, val.value<QColor>() );
case QMetaType::QPalette:
return Slot::setPalette( slot, val.value<QPalette>() );
case QMetaType::Float:
case QMetaType::Double:
SetFloat( slot, val.value<double>() );
return errNone;
case QMetaType::Int:
SetInt( slot, val.toInt() );
return errNone;
case QMetaType::QObjectStar:
Slot::setQObject( slot, val.value<QObject*>() );
return errNone;
case QMetaType::QWidgetStar:
Slot::setQObject( slot, val.value<QWidget*>() );
return errNone;
case QMetaType::Void:
SetNil( slot );
return errNone;
default:
if( type == qMetaTypeId<PyrObject*>() ) {
SetObject( slot, val.value<PyrObject*>() );
}
else if( type == qMetaTypeId<VariantList>() ) {
Slot::setVariantList( slot, val.value<VariantList>() );
}
else if( type == qMetaTypeId<QcTreeWidget::ItemPtr>() ) {
Slot::setTreeWidgetItem( slot, val.value< QtCollider::SafePtr<QcTreeWidget::Item> >() );
}
else {
qcErrorMsg( "the QVariant could not be interpreted!" );
return errFailed;
}
return errNone;
}
}
示例14: updateEffectState
void ShaderEffectItem::updateEffectState(const QMatrix4x4 &matrix)
{
for (int i = m_sources.size() - 1; i >= 0; --i) {
const ShaderEffectItem::SourceData &source = m_sources.at(i);
if (!source.source)
continue;
glActiveTexture(GL_TEXTURE0 + i);
source.source->bind();
}
if (m_respectsOpacity)
m_program.setUniformValue("qt_Opacity", static_cast<float> (effectiveOpacity()));
if (m_respectsMatrix){
m_program.setUniformValue("qt_ModelViewProjectionMatrix", matrix);
}
QSet<QByteArray>::const_iterator it;
for (it = m_uniformNames.begin(); it != m_uniformNames.end(); ++it) {
const QByteArray &name = *it;
QVariant v = property(name.constData());
switch (v.type()) {
case QVariant::Color:
m_program.setUniformValue(name.constData(), qvariant_cast<QColor>(v));
break;
case QVariant::Double:
m_program.setUniformValue(name.constData(), (float) qvariant_cast<double>(v));
break;
case QVariant::Transform:
m_program.setUniformValue(name.constData(), qvariant_cast<QTransform>(v));
break;
case QVariant::Int:
m_program.setUniformValue(name.constData(), v.toInt());
break;
case QVariant::Bool:
m_program.setUniformValue(name.constData(), GLint(v.toBool()));
break;
case QVariant::Size:
case QVariant::SizeF:
m_program.setUniformValue(name.constData(), v.toSizeF());
break;
case QVariant::Point:
case QVariant::PointF:
m_program.setUniformValue(name.constData(), v.toPointF());
break;
case QVariant::Rect:
case QVariant::RectF:
{
QRectF r = v.toRectF();
m_program.setUniformValue(name.constData(), r.x(), r.y(), r.width(), r.height());
}
break;
case QVariant::Vector3D:
m_program.setUniformValue(name.constData(), qvariant_cast<QVector3D>(v));
break;
default:
break;
}
}
}
示例15: displayString
QString VariantHandler::displayString(const QVariant& value)
{
switch (value.type()) {
#ifndef QT_NO_CURSOR
case QVariant::Cursor:
{
const QCursor cursor = value.value<QCursor>();
return Util::enumToString(QVariant::fromValue<int>(cursor.shape()), "Qt::CursorShape");
}
#endif
case QVariant::Icon:
{
const QIcon icon = value.value<QIcon>();
if (icon.isNull()) {
return QObject::tr("<no icon>");
}
QStringList l;
foreach (const QSize &size, icon.availableSizes()) {
l.push_back(displayString(size));
}
return l.join(QLatin1String(", "));
}
case QVariant::Line:
return
QString::fromUtf8("%1 x %2 → %3 x %4").
arg(value.toLine().x1()).arg(value.toLine().y1()).
arg(value.toLine().x2()).arg(value.toLine().y2());
case QVariant::LineF:
return
QString::fromUtf8("%1 x %2 → %3 x %4").
arg(value.toLineF().x1()).arg(value.toLineF().y1()).
arg(value.toLineF().x2()).arg(value.toLineF().y2());
case QVariant::Locale:
return value.value<QLocale>().name();
case QVariant::Point:
return
QString::fromLatin1("%1x%2").
arg(value.toPoint().x()).
arg(value.toPoint().y());
case QVariant::PointF:
return
QString::fromLatin1("%1x%2").
arg(value.toPointF().x()).
arg(value.toPointF().y());
case QVariant::Rect:
return
QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRect().x()).
arg(value.toRect().y()).
arg(value.toRect().width()).
arg(value.toRect().height());
case QVariant::RectF:
return
QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRectF().x()).
arg(value.toRectF().y()).
arg(value.toRectF().width()).
arg(value.toRectF().height());
case QVariant::Region:
{
const QRegion region = value.value<QRegion>();
if (region.isEmpty()) {
return QLatin1String("<empty>");
}
if (region.rectCount() == 1) {
return displayString(region.rects().first());
} else {
return QString::fromLatin1("<%1 rects>").arg(region.rectCount());
}
}
case QVariant::Palette:
{
const QPalette pal = value.value<QPalette>();
if (pal == qApp->palette()) {
return QLatin1String("<inherited>");
}
return QLatin1String("<custom>");
}
case QVariant::Size:
return
QString::fromLatin1("%1x%2").
arg(value.toSize().width()).
arg(value.toSize().height());
case QVariant::SizeF:
return
QString::fromLatin1("%1x%2").
arg(value.toSizeF().width()).
arg(value.toSizeF().height());
case QVariant::StringList:
//.........这里部分代码省略.........