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


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

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


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

示例1: onActionMouseInOut

void KNMusicHeaderPlayer::onActionMouseInOut(const QVariant &controlPos)
{
    QPoint controlPosition=controlPos.toPoint();
    m_textPalette.setColor(QPalette::WindowText, QColor(255,255,255,-controlPosition.y()*5));
    m_title->setPalette(m_textPalette);
    m_artistAlbum->setPalette(m_textPalette);
}
开发者ID:Kreogist,项目名称:Nerve,代码行数:7,代码来源:knmusicheaderplayer.cpp

示例2: 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;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:35,代码来源:qgraphicsproxywidget.cpp

示例3: setValue

void KPointComposedProperty::setValue(KProperty *property,
    const QVariant &value, bool rememberOldValue)
{
    const QPoint p( value.toPoint() );
    property->child("x")->setValue(p.x(), rememberOldValue, false);
    property->child("y")->setValue(p.y(), rememberOldValue, false);
}
开发者ID:KDE,项目名称:kproperty,代码行数:7,代码来源:pointedit.cpp

示例4: setOption

bool EnlargeShrink::setOption(const QString &option, const QVariant &value)
{
    bool ok = false;

    if (option == QuillImageFilter::Radius) {
        double radius = value.toDouble(&ok);
        if (ok) {
            m_Radius = radius;
        }

    } else if (option == QuillImageFilter::Center) {
        QPoint center = value.toPoint();
        if (!center.isNull()) {
            m_Center = center;
            ok = true;
        }

    } else if (option == FORCE_OPTION) {
        double force = value.toDouble(&ok);
        ok = ok && force <= 1.0 && force >= -1.0;
        if (ok) {
            // Divide by the FORCE_FACTOR to get appropiated values for
            // the Amplitude used by the "distort" function
            m_Force = force/FORCE_FACTOR;
        }
    }

    return ok;
}
开发者ID:Igalia,项目名称:gallery-enlarge-shrink-plugin,代码行数:29,代码来源:enlargeshrink.cpp

示例5: PackValue

QString CSpmXml::PackValue(const QVariant& vtValue)
{
	QString strValue;

	switch (vtValue.type())
	{
	case QVariant::Size:
		{
			QSize size = vtValue.toSize();
			strValue.sprintf(":%s:%d:%d", vtValue.typeName(), size.width(), size.height());
		}
		break;
	case QVariant::Point:
		{
			QPoint pt = vtValue.toPoint();
			strValue.sprintf(":%s:%d:%d", vtValue.typeName(), pt.x(), pt.y());
		}
		break;

	default:
		strValue = vtValue.toString();
		break;
	};	

	return strValue;
}
开发者ID:smurav,项目名称:gis36,代码行数:26,代码来源:spmxml.cpp

示例6: itemChange

QVariant GraphicsComponent::itemChange(GraphicsItemChange change, const QVariant &value)
{

    switch (change)
    {
    case ItemPositionChange:
        {
            emit itemMoved(this);
            QPoint pos = value.toPoint();
            if (this->parent->getSnapToGrid()){
                pos = this->calculateSnap(pos);
                this->setProperty("x", pos.x());
                this->setProperty("y", pos.y());
                return QGraphicsItem::itemChange(change, QVariant(pos));
            }

            this->setProperty("x", this->x());
            this->setProperty("y", this->y());

        }
        break;
    case ItemSelectedChange:
        break;
    default:
        break;

    }

     return QGraphicsItem::itemChange(change, value);

}
开发者ID:pannitan,项目名称:OpenADCAD,代码行数:31,代码来源:graphicscomponent.cpp

示例7: displayText

QString PointDelegate::displayText( const QVariant& value ) const
{
    const QPoint p(value.toPoint());
    return QString::fromLatin1(POINTEDIT_MASK)
        .arg(p.x())
        .arg(p.y());
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:7,代码来源:pointedit.cpp

示例8: 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,代码来源:

示例9: SetupUi

void MainWindow::SetupUi()
{
	resize(600, 400);

	//set the main toolbar	
	mainToolbar = new QToolBar();
	mainToolbar->setEnabled(true);
	mainToolbar->setIconSize(QSize(16, 16));
	addToolBar(Qt::TopToolBarArea, mainToolbar);

	newAction = new QAction(QIcon(":/Resources/images/new.png"), tr("&New"), this);
	connect(newAction, SIGNAL(triggered()), this, SLOT(OnNew()));
	mainToolbar->addAction(newAction);

	openAction = new QAction(QIcon(":/Resources/images/open.png"), tr("&Open"), this);
	openAction->setShortcut(QKeySequence::Open);
	connect(openAction, SIGNAL(triggered()), this, SLOT(OnOpen()));
	mainToolbar->addAction(openAction);

	saveAction = new QAction(QIcon(":/Resources/images/save.png"), tr("&Save"), this);
	saveAction->setShortcut(QKeySequence::Save);
	connect(saveAction, SIGNAL(triggered()), this, SLOT(OnSave()));
	mainToolbar->addAction(saveAction);

	undoAction = new QAction(QIcon(":/Resources/images/undo.png"), tr("&Undo"), this);
	undoAction->setShortcut(QKeySequence::Undo);
	connect(undoAction, SIGNAL(triggered()), this, SLOT(OnUndo()));
	mainToolbar->addAction(undoAction);

	redoAction = new QAction(QIcon(":/Resources/images/redo.png"), tr("&Redo"), this);
	redoAction->setShortcut(QKeySequence::Redo);
	connect(redoAction, SIGNAL(triggered()), this, SLOT(OnRedo()));
	mainToolbar->addAction(redoAction);

	setWindowTitle(QApplication::translate("Natural Calculator", "Natural Calculator", 0, QApplication::UnicodeUTF8));
	QMetaObject::connectSlotsByName(this);

	QVariant p = settings.Load("NaturalCalculator", "position");
	move(p.toPoint());
	p = settings.Load("NaturalCalculator", "size");
	resize(p.toSize());
	
	//set the main window
	formulaWnd = new FormulaWnd(this);
	formulaWnd->setObjectName(QString::fromUtf8("formulaWnd"));
	formulaWnd->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

	QWidget* c = new QWidget();
	
	QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
	layout->addWidget(formulaWnd);

	c->setLayout(layout);
	setCentralWidget(c);
}
开发者ID:denprog,项目名称:NaturalCalculator,代码行数:55,代码来源:MainWindow.cpp

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

示例11: showEvent

void Window::showEvent(QShowEvent* event) {
	resizeFrame(m_screenWidget->sizeHint().width(), m_screenWidget->sizeHint().height());
	QVariant windowPos = m_config->getQtOption("windowPos");
	if (!windowPos.isNull()) {
		move(windowPos.toPoint());
	} else {
		QRect rect = frameGeometry();
		rect.moveCenter(QApplication::desktop()->availableGeometry().center());
		move(rect.topLeft());
	}
}
开发者ID:zerofalcon,项目名称:mgba,代码行数:11,代码来源:Window.cpp

示例12: displayText

QString VariantDelegate::displayText(const QVariant &value)
{
    switch (value.type()) {
    case QVariant::Bool:
    case QVariant::ByteArray:
    case QVariant::Char:
    case QVariant::Double:
    case QVariant::Int:
    case QVariant::LongLong:
    case QVariant::String:
    case QVariant::UInt:
    case QVariant::ULongLong:
        return value.toString();
    case QVariant::Color:
        {
            QColor color = qvariant_cast<QColor>(value);
            return QString("(%1,%2,%3,%4)")
                   .arg(color.red()).arg(color.green())
                   .arg(color.blue()).arg(color.alpha());
        }
    case QVariant::Date:
        return value.toDate().toString(Qt::ISODate);
    case QVariant::DateTime:
        return value.toDateTime().toString(Qt::ISODate);
    case QVariant::Invalid:
        return "<Invalid>";
    case QVariant::Point:
        {
            QPoint point = value.toPoint();
            return QString("(%1,%2)").arg(point.x()).arg(point.y());
        }
    case QVariant::Rect:
        {
            QRect rect = value.toRect();
            return QString("(%1,%2,%3,%4)")
                   .arg(rect.x()).arg(rect.y())
                   .arg(rect.width()).arg(rect.height());
        }
    case QVariant::Size:
        {
            QSize size = value.toSize();
            return QString("(%1,%2)").arg(size.width()).arg(size.height());
        }
    case QVariant::StringList:
        return value.toStringList().join(',');
    case QVariant::Time:
        return value.toTime().toString(Qt::ISODate);
    default:
        break;
    }
    return QString("<%1>").arg(value.typeName());
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:52,代码来源:variantdelegate.cpp

示例13: loadItemPositions

void DesktopWindow::loadItemPositions() {
    // load custom item positions
    customItemPos_.clear();
    Settings& settings = static_cast<Application*>(qApp)->settings();
    QString configFile = QString("%1/desktop-items-%2.conf").arg(settings.profileDir(settings.profileName())).arg(screenNum_);
    QSettings file(configFile, QSettings::IniFormat);

    auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
    auto grid = delegate->itemSize();
    QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
    workArea.adjust(12, 12, -12, -12);
    char* dektopPath = Fm::Path::getDesktop().toStr();
    QString desktopDir = QString(dektopPath) + QString("/");
    g_free(dektopPath);

    std::vector<QPoint> usedPos;
    for(auto& item: customItemPos_) {
        usedPos.push_back(item.second);
    }

    // FIXME: this is inefficient
    Q_FOREACH(const QString& name, file.childGroups()) {
        if(!QFile::exists(desktopDir + name.toUtf8())) {
            // the file may have been removed from outside LXQT
            continue;
        }
        file.beginGroup(name);
        QVariant var = file.value("pos");
        if(var.isValid()) {
            QPoint customPos = var.toPoint();
            if(customPos.x() >= workArea.x() && customPos.y() >= workArea.y()
                    && customPos.x() + grid.width() <= workArea.right() + 1
                    && customPos.y() + grid.height() <= workArea.bottom() + 1) {
                // correct positions that are't aligned to the grid
                alignToGrid(customPos, workArea.topLeft(), grid, listView_->spacing());
                // FIXME: this is very inefficient
                while(std::find(usedPos.cbegin(), usedPos.cend(), customPos) != usedPos.cend()) {
                    customPos.setY(customPos.y() + grid.height() + listView_->spacing());
                    if(customPos.y() + grid.height() > workArea.bottom() + 1) {
                        customPos.setX(customPos.x() + grid.width() + listView_->spacing());
                        customPos.setY(workArea.top());
                    }
                }
                customItemPos_[name.toStdString()] = customPos;
                usedPos.push_back(customPos);
            }
        }
        file.endGroup();
    }
}
开发者ID:SafaAlfulaij,项目名称:pcmanfm-qt,代码行数:50,代码来源:desktopwindow.cpp

示例14: setOption

bool RedEyeDetection::setOption(const QString &option, const QVariant &value)
{
    bool bOk = true;

    if (option == QuillImageFilter::Center)
        priv->center = value.toPoint();
    else if (option == QuillImageFilter::Radius)
	priv->eyeRadius = value.toInt(&bOk);
    else if (option == QuillImageFilter::Tolerance)
	priv->tapErrorTolerance = value.toInt(&bOk);
    else
        bOk = false;

    return bOk;
}
开发者ID:amtep,项目名称:quillimagefilters,代码行数:15,代码来源:redeyedetection.cpp

示例15: setOption

bool TiltShift::setOption(const QString& filterOption, const QVariant& value)
{
    bool result = true;
    if (filterOption == QuillImageFilter::Radius) {
        m_radius = value.toInt();
    } else if (filterOption == QuillImageFilter::Horizontal) {
        m_horizontalEffect = value.toBool();
    } else if (filterOption == QuillImageFilter::Center) {
        m_focusPoint = value.toPoint();
    } else {
        result = false;
    }

    return result;
}
开发者ID:Igalia,项目名称:gallery-tiltshift-plugin,代码行数:15,代码来源:tiltshift.cpp


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