本文整理汇总了C++中QVariant::toPointF方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toPointF方法的具体用法?C++ QVariant::toPointF怎么用?C++ QVariant::toPointF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toPointF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemChange
QVariant MapObjectItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (!mSyncing) {
MapRenderer *renderer = mMapDocument->renderer();
if (change == ItemPositionChange
&& (QApplication::keyboardModifiers() & Qt::ControlModifier))
{
const QPointF pixelDiff = value.toPointF() - mOldItemPos;
const QPointF newPixelPos =
renderer->tileToPixelCoords(mOldObjectPos) + pixelDiff;
// Snap the position to the grid
const QPointF newTileCoords =
renderer->pixelToTileCoords(newPixelPos).toPoint();
return renderer->tileToPixelCoords(newTileCoords);
}
else if (change == ItemPositionHasChanged) {
// Update the position of the map object
const QPointF pixelDiff = value.toPointF() - mOldItemPos;
const QPointF newPixelPos =
renderer->tileToPixelCoords(mOldObjectPos) + pixelDiff;
mObject->setPosition(renderer->pixelToTileCoords(newPixelPos));
}
}
return QGraphicsItem::itemChange(change, value);
}
示例2: itemChange
QVariant EqHandle::itemChange( QGraphicsItem::GraphicsItemChange change, const QVariant &value )
{
if( change == ItemPositionChange )
{
// pass filter don't move in y direction
if ( m_type == highpass || m_type == lowpass )
{
float newX = value.toPointF().x();
if( newX < 0 )
{
newX = 0;
}
if( newX > m_width )
{
newX = m_width;
}
return QPointF(newX, m_heigth/2);
}
}
QPointF newPos = value.toPointF();
QRectF rect = QRectF( 0, 0, m_width, m_heigth );
if( !rect.contains( newPos ) )
{
// Keep the item inside the scene rect.
newPos.setX( qMin( rect.right(), qMax( newPos.x(), rect.left() ) ) );
newPos.setY( qMin( rect.bottom(), qMax( newPos.y(), rect.top() ) ) );
return newPos;
}
return QGraphicsItem::itemChange( change, value );
}
示例3: data
QVariant TrajectoriesProxyModel::data(const QModelIndex &proxyIndex, int role) const
{
if (role != Qt::DisplayRole ||
!proxyIndex.isValid() ||
!_parentIndex.isValid()) {
return QVariant();
}
if (!proxyIndex.parent().isValid()) {
return proxyIndex.column() == 0? tr("Trajectory %1").arg(proxyIndex.row()) : QVariant();
}
QVariant data = mapToSource(proxyIndex).data();
switch (proxyIndex.column()) {
case VideoModel::LFrameColumn:
return data;
case VideoModel::PositionColumn:
return tr("(%1, %2)").arg(data.toPointF().x()).arg(data.toPointF().y());
case VideoModel::LSpeedColumn:
case VideoModel::LAccelerationColumn:
return QLineF(QPointF(0, 0), data.toPointF()).length();
default:
return QVariant();
}
}
示例4: itemChange
QVariant GraphicsClientItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemPositionHasChanged) {
if (jackClient) {
jackClient->setClientItemPosition(value.toPointF());
} else {
clientItemsClient->setClientItemPositionByName(clientName, value.toPointF());
}
}
return QGraphicsPathItem::itemChange(change, value);
}
示例5: itemChange
QVariant MeshGraphItemVelocityHandle::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change)
{
case QGraphicsItem::ItemPositionHasChanged:
m_station->setVelocity(value.toPointF());
m_arrow->setEdges(QPointF(0, 0), value.toPointF());
m_station->stationChanged();
updateText();
break;
default:
break;
};
return QGraphicsItem::itemChange(change, value);
}
示例6: itemChange
/**
* @brief itemChange handle detail change.
* @param change change
* @param value value
* @return new value.
*/
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionHasChanged && scene())
{
// value - this is new position.
QPointF newPos = value.toPointF();
MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, this->scene());
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(moveDet);
}
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
示例7: 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;
}
示例8: setValue
void PointFComposedProperty::setValue(Property *property,
const QVariant &value, bool rememberOldValue)
{
const QPointF p( value.toPointF() );
property->child("x")->setValue(p.x(), rememberOldValue, false);
property->child("y")->setValue(p.y(), rememberOldValue, false);
}
示例9: itemChange
QVariant SceneItem::itemChange(GraphicsItemChange change, const QVariant& value) {
if (scene() && change == QGraphicsItem::ItemPositionChange) {
QPointF newPos = value.toPointF();
// rect is adjusted so that items cannot be placed one tile to the right/bottom
int adjust = -TILE_SIZE;
QRectF rect = scene()->sceneRect().adjusted(0, 0, adjust, adjust);
if (!rect.contains(newPos)) {
// don't allow the item to be moved outside the scene
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
}
newPos.setX(round(newPos.x() / TILE_SIZE) * TILE_SIZE);
newPos.setY(round(newPos.y() / TILE_SIZE) * TILE_SIZE);
return newPos;
} else if (change == QGraphicsItem::ItemPositionHasChanged) {
// update the position of the sprite/exit (or whatever) based on the new position
// TODO: generate undo/redo actions for movement somehow
this->updateObject();
return value;
}
return QGraphicsItem::itemChange(change, value);
}
示例10: itemChange
QVariant QBayesNode::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case QGraphicsItem::ItemSelectedChange:
mIsSelected = value.toBool();
if (mIsSelected)
setFocus();
break;
case QGraphicsItem::ItemPositionChange:
{
if (scene()) {
// value is the new position.
QPointF newPos = value.toPointF();
QRectF sceneRect = scene()->sceneRect();
if (!sceneRect.contains(newPos)) {
// Keep the item inside the scene rect.
newPos.setX(qMin(sceneRect.right(), qMax(newPos.x(), sceneRect.left())));
newPos.setY(qMin(sceneRect.bottom(), qMax(newPos.y(), sceneRect.top())));
}
emit positionChanged(newPos);
update();
return QGraphicsItem::itemChange(change, newPos);
}
break;
}
default:
break;
}
return QGraphicsItem::itemChange(change, value);
}
示例11: itemChange
QVariant Component::itemChange(GraphicsItemChange change,
const QVariant &value) {
if (change == ItemPositionChange && scene()) {
int i = 0;
// QList<Connection *> connectionlist = scene->getConnections();
// qDebug() << "connections are " + QString::number(m);
// foreach (Connection *connection, connections)
// {
// connection->updatePosition();
// qDebug() << i++;
// }
}
if (change == ItemPositionChange && scene()) {
// value is the new position.
QPointF newPos = value.toPointF();
QRectF rect = scene()->sceneRect();
if (!rect.contains(newPos)) {
// Keep the item inside the scene rect.
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
return newPos;
}
}
return QGraphicsItem::itemChange(change, value);
}
示例12: changeElementInModel
void RefactoringApplier::changeElementInModel(const Id &changeFromId, const Id &changeToId)
{
if (mLogicalModelApi.isLogicalId(changeFromId)) {
return;
}
if (!refactoringElements.contains(changeToId.element())) {
IdList const inLinks = mGraphicalModelApi.mutableGraphicalRepoApi().incomingLinks(changeFromId);
IdList const outLinks = mGraphicalModelApi.mutableGraphicalRepoApi().outgoingLinks(changeFromId);
Id const parentId = mGraphicalModelApi.mutableGraphicalRepoApi().parent(changeFromId);
QVariant const position = mGraphicalModelApi.mutableGraphicalRepoApi().position(changeFromId);
bool const isFromLogicalModel = false;
QString const refactoringsMetamodel = "RefactoringsMetamodel";
QString newEditor = changeToId.editor();
newEditor.chop(refactoringsMetamodel.length());
Id const newId = Id(newEditor, changeToId.diagram(), changeToId.element(), QUuid::createUuid().toString());
Id const newElementId = mGraphicalModelApi.createElement(parentId, newId
, isFromLogicalModel, "ololo", position.toPointF());
for (Id idLink : inLinks) {
mGraphicalModelApi.mutableGraphicalRepoApi().setTo(idLink, newElementId);
}
for (Id idLink : outLinks) {
mGraphicalModelApi.mutableGraphicalRepoApi().setFrom(idLink, newElementId);
}
mGraphicalModelApi.mutableGraphicalRepoApi().removeChild(parentId, changeFromId);
mGraphicalModelApi.mutableGraphicalRepoApi().removeElement(changeFromId);
}
}
示例13: setValue
void Mapper::setValue(QtProperty* property, const QVariant& value)
{
if (property == _opacityItem)
{
double opacity = qBound(value.toDouble() / 100.0, 0.0, 1.0);
if (opacity != _mapping->getRawOpacity())
{
_mapping->setRawOpacity(opacity);
emit valueChanged();
}
}
else
{
std::map<QtProperty*, std::pair<MShape*, int> >::iterator it = _propertyToVertex.find(property);
if (it != _propertyToVertex.end())
{
const QPointF& p = value.toPointF();
MShape* shape = it->second.first;
int v = it->second.second;
if (shape->getVertex(v) != p)
{
shape->setVertex(v, p);
emit valueChanged();
}
}
}
}
示例14: itemChange
QVariant KWidget::itemChange( GraphicsItemChange change, const QVariant & value )
{
if(change == QGraphicsItem::ItemParentHasChanged
|| change == QGraphicsItem::ItemParentChange)
{
clearThemeCheckFlag();
}
else if(change == QGraphicsItem::ItemScenePositionHasChanged)
{
emit scenePosition(value.toPointF());
}
else if(change == QGraphicsItem::ItemVisibleHasChanged)
{
bool bvis = isVisible();
visibleEvent(bvis);
if(bvis)
{
showEvent();
}
else
{
hideEvent();
}
}
return QGraphicsWidget::itemChange(change, value);
}
示例15: itemChange
QVariant GraphicEQFilterGUIItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
{
QVariant result = QGraphicsItem::itemChange(change, value);
if (change == ItemScenePositionHasChanged)
{
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
s->itemMoved(index);
}
else if (change == ItemSelectedHasChanged)
{
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
s->itemSelectionChanged(index, value.toBool());
}
else if (change == ItemPositionChange)
{
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
if (s->getBandCount() != -1)
{
QPointF newPos = value.toPointF();
newPos.setX(s->hzToX(getHz()));
result = newPos;
}
}
return result;
}