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


C++ QRectF::moveTopLeft方法代码示例

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


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

示例1: _constrainPosition

void WindowController::_constrainPosition(QRectF& window) const
{
    const auto& group = _group.getCoordinates();

    if (_targetIsFullscreen())
    {
        const auto overlapX = group.width() - window.width();
        const auto overlapY = group.height() - window.height();

        const auto minX = overlapX < 0.0 ? overlapX : 0.5 * overlapX;
        const auto minY = overlapY < 0.0 ? overlapY : 0.5 * overlapY;

        const auto maxX = 0.0;
        const auto maxY = 0.0;

        window.moveTopLeft({std::max(minX, std::min(window.x(), maxX)),
                            std::max(minY, std::min(window.y(), maxY))});
        return;
    }

    const auto minX = ui::getMinWindowSize() - window.width();
    const auto minY = ui::getMinWindowSize() - window.height();

    const auto maxX = group.width() - ui::getMinWindowSize();
    const auto maxY = group.height() - ui::getMinWindowSize();

    window.moveTopLeft({std::max(minX, std::min(window.x(), maxX)),
                        std::max(minY, std::min(window.y(), maxY))});
}
开发者ID:BlueBrain,项目名称:Tide,代码行数:29,代码来源:WindowController.cpp

示例2: paint

void OnMonitorRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    Q_UNUSED(widget)
    Q_UNUSED(option)

    painter->setPen(pen());
    //painter->setClipRect(option->rect);
    const QRectF r = rect();
    painter->drawRect(r);
    QRectF handle = painter->worldTransform().inverted().mapRect(QRectF(0, 0, 6, 6));
    if (isEnabled()) {
        handle.moveTopLeft(r.topLeft());
        painter->fillRect(handle, QColor(Qt::yellow));
        handle.moveTopRight(r.topRight());
        painter->fillRect(handle, QColor(Qt::yellow));
        handle.moveBottomLeft(r.bottomLeft());
        painter->fillRect(handle, QColor(Qt::yellow));
        handle.moveBottomRight(r.bottomRight());
        painter->fillRect(handle, QColor(Qt::yellow));
    }
    
    // Draw cross at center
    QPointF center = r.center();
    painter->drawLine(center + QPointF(-handle.width(), 0), center + QPointF(handle.width(), 0));
    painter->drawLine(center + QPointF(0, handle.height()), center + QPointF(0, -handle.height()));
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:26,代码来源:onmonitorrectitem.cpp

示例3: setSceneRect

void QgsComposerScaleBar::setSceneRect( const QRectF& rectangle )
{
  QRectF box = mStyle->calculateBoxSize();
  if ( rectangle.height() > box.height() )
  {
    //keep user specified item height if higher than minimum scale bar height
    box.setHeight( rectangle.height() );
  }
  box.moveTopLeft( rectangle.topLeft() );

  //update rect for data defined size and position
  QRectF newRect = evalItemRect( rectangle );

  //scale bars have a minimum size, respect that regardless of data defined settings
  if ( newRect.width() < box.width() )
  {
    newRect.setWidth( box.width() );
  }
  if ( newRect.height() < box.height() )
  {
    newRect.setHeight( box.height() );
  }

  QgsComposerItem::setSceneRect( newRect );
}
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:25,代码来源:qgscomposerscalebar.cpp

示例4: boundingRect

QRectF
FormCheckBox::rectangle() const
{
	QRectF r = boundingRect();
	r.moveTopLeft( position() );

	return r;
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:8,代码来源:form_checkbox.cpp

示例5: fromStored

QPointF SymbolDataEditor::fromStored(const QPointF &point) const
{
    QPointF result;
    QRectF symbolRect = scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->boundingRect();
    symbolRect.moveTopLeft(scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->pos());
    result.rx() = point.x() * symbolRect.width();
    result.ry() = point.y() * symbolRect.height();
    result += symbolRect.topLeft();
    return result;
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:10,代码来源:symboldataeditor.cpp

示例6: toStored

QPointF SymbolDataEditor::toStored(const QPointF &point) const
{
    QRectF symbolRect = scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->boundingRect();
    symbolRect.moveTopLeft(scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->pos());
    QPointF result = point - symbolRect.topLeft();
    result.rx() = point.x() / symbolRect.width();
    result.ry() = point.y() / symbolRect.height();
    result -= QPointF(2.0,2.0); //WARNING: I don't know why this works, but it depends on SvgView::scaleViewBox()
    return result;
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:10,代码来源:symboldataeditor.cpp

示例7: saveDimensions

void LabelItemDialog::saveDimensions(ViewItem *viewitem) {
  Q_ASSERT(viewitem);

  LabelItem *item = qobject_cast<LabelItem*>(viewitem);
  Q_ASSERT(item);

  QPointF xy(_labelDimensionsTab->x(),_labelDimensionsTab->y());
  qreal theta = _labelDimensionsTab->rotation();
  bool fix_left = _labelDimensionsTab->fixLeft();

  if (_labelDimensionsTab->lockPosToData() && item->dataPosLockable()) {
    QRectF dr = item->dataRelativeRect();
    if (fix_left) {
      dr.moveTopLeft(xy);
      item->setFixLeft(true);
    } else {
      dr.moveBottomRight(xy);
      item->setFixLeft(false);
    }
    item->setDataRelativeRect(dr);

    bool lockPosToData = _labelDimensionsTab->lockPosToDataDirty() ? _labelDimensionsTab->lockPosToData() : item->lockPosToData();
    item->setLockPosToData(lockPosToData);

    item->applyDataLockedDimensions();

  } else {
    QRectF parentRect = item->parentRect();
    qreal parentWidth = parentRect.width();
    qreal parentHeight = parentRect.height();
    qreal parentX = parentRect.x();
    qreal parentY = parentRect.y();
    bool lockPosToData = _labelDimensionsTab->lockPosToDataDirty() ? _labelDimensionsTab->lockPosToData() : item->lockPosToData();
    item->setLockPosToData(lockPosToData);
    qreal width = item->rect().width();
    qreal height = item->rect().height();

    item->setPos(parentX + xy.x()*parentWidth, parentY + xy.y()*parentHeight);
    if (fix_left) {
      item->setViewRect(0,-height, width, height);
      item->setFixLeft(true);
    } else {
      item->setViewRect(-width,-height, width, height);
      item->setFixLeft(false);
    }
  }
  QTransform transform;
  transform.rotate(theta);
  item->setTransform(transform);
  item->updateRelativeSize(true);

  if (_saveAsDefault->isChecked()) {
    _dialogDefaults->setValue(item->staticDefaultsGroupName()+"/fixLeft",_labelDimensionsTab->fixLeft());
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:55,代码来源:labelitemdialog.cpp

示例8: setTargetItem

void ItemBackground::setTargetItem(QGraphicsItem *target)
{
    if (d->target && d->target != target) {
        QObject *obj = 0;
        if (d->target->isWidget()) {
            obj = static_cast<QGraphicsWidget*>(d->target);
            obj->removeEventFilter(this);
        } else {
            d->target->removeSceneEventFilter(this);
            obj = dynamic_cast<QObject *>(d->target);
        }

        if (obj) {
            disconnect(obj, 0, this, 0);
        }
    }

    if (!target) {
        hide();
    }

    bool newTarget = (d->target != target);
    d->target = target;
    if (target) {
        setZValue(target->zValue() - 1);
        if (parentItem() != target->parentItem()) {
            QTransform t = transform();
            setTransform(QTransform());
            QRectF geom = mapToScene(geometry()).boundingRect();
            setGeometry(mapFromScene(geom).boundingRect());
            setTransform(t);
        }

        QRectF rect = target->boundingRect();
        rect.moveTopLeft(mapToParent(mapFromScene(target->mapToScene(QPointF(0, 0)))));

        setTarget(rect);


        if (newTarget) {
            QObject *obj = 0;
            if (target->isWidget()) {
                obj = static_cast<QGraphicsWidget*>(target);
                obj->installEventFilter(this);
            } else {
                d->target->installSceneEventFilter(this);
                obj = dynamic_cast<QObject *>(target);
            }

            if (obj) {
                connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed(QObject*)));
            }
        }
    }
}
开发者ID:vasi,项目名称:kdelibs,代码行数:55,代码来源:itembackground.cpp

示例9: QPointF

void
FormComboBoxPrivate::setRect( const QRectF & rect )
{
	m_rect = rect;

	q->setPos( m_rect.topLeft() );

	m_proxy->setRect( m_rect );

	m_rect.moveTopLeft( QPointF( 0.0, 0.0 ) );
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:11,代码来源:form_combobox.cpp

示例10: form

void
FormCheckBox::setPosition( const QPointF & pos, bool pushUndoCommand )
{
	if( pushUndoCommand )
		form()->undoStack()->push( new UndoMove< FormCheckBox > ( form(),
			objectId(), pos - position() ) );

	QRectF r = boundingRect();
	r.moveTopLeft( pos );

	d->setRect( r );
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:12,代码来源:form_checkbox.cpp

示例11: QRectF

QRectF
FormResizableProxy::boundingRect() const
{
	if( !d.isNull() )
	{
		QRectF r = d->m_rect;
		r.moveTopLeft( QPointF( 0.0, 0.0 ) );

		return r.adjusted( -12.0, -12.0, 12.0, 12.0 );
	}
	else
		return QRectF();
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:13,代码来源:form_resizable.cpp

示例12: mouseMoveSignal

void PlotController::mouseMoveSignal(QMouseEvent *event) {
    if (dragging_legend) {
        QRectF rect = roi_plot->axisRect()->insetLayout()->insetRect(0);

        QPointF mousePoint((event->pos().x() - roi_plot->axisRect()->left()) /
                           (double) roi_plot->axisRect()->width(),
                           (event->pos().y() - roi_plot->axisRect()->top()) /
                           (double) roi_plot->axisRect()->height());
        rect.moveTopLeft(mousePoint - drag_legend_origin);
        roi_plot->axisRect()->insetLayout()->setInsetRect(0, rect);
        roi_plot->replot();
    }
}
开发者ID:vsteiger,项目名称:murfi2,代码行数:13,代码来源:PlotController.cpp

示例13:

void
Context::Applet::drawRoundedRectAroundText( QPainter* p, QGraphicsSimpleTextItem* t )
{

   p->setRenderHint( QPainter::Antialiasing );
   QColor col = PaletteHandler::highlightColor().lighter( 150 );
   p->save();
   QRectF rect = t->boundingRect();
   rect.moveTopLeft( t->pos() );
   QPainterPath path;
   path.addRoundedRect( rect.adjusted( -5, -2, 5, 2 ), 3, 3 );

   p->fillPath( path, col );
   p->restore();
   // draw outline around textbox
   p->save();
   col = PaletteHandler::highlightColor( 0.3, .5 );
   p->setPen( col );
   rect = t->boundingRect();
   rect.moveTopLeft( t->pos() );
   p->drawRoundedRect( rect.adjusted( -5, -2, 5, 2 ), 3, 3 );
   p->restore(); 
}
开发者ID:weiligang512,项目名称:apue-test,代码行数:23,代码来源:Applet.cpp

示例14: addImage

void QQuickTextNodeEngine::addImage(const QRectF &rect, const QImage &image, qreal ascent,
                                    SelectionState selectionState,
                                    QTextFrameFormat::Position layoutPosition)
{
    QRectF searchRect = rect;
    if (layoutPosition == QTextFrameFormat::InFlow) {
        if (m_currentLineTree.isEmpty()) {
            searchRect.moveTopLeft(m_position + m_currentLine.position() + QPointF(0,1));
        } else {
            const BinaryTreeNode *lastNode = m_currentLineTree.data() + m_currentLineTree.size() - 1;
            if (lastNode->glyphRun.isRightToLeft()) {
                QPointF lastPos = lastNode->boundingRect.topLeft();
                searchRect.moveTopRight(lastPos - QPointF(0, ascent - lastNode->ascent));
            } else {
                QPointF lastPos = lastNode->boundingRect.topRight();
                searchRect.moveTopLeft(lastPos - QPointF(0, ascent - lastNode->ascent));
            }
        }
    }

    BinaryTreeNode::insert(&m_currentLineTree, searchRect, image, ascent, selectionState);
    m_hasContents = true;
}
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:23,代码来源:qquicktextnodeengine.cpp

示例15: _constrainPosition

void ContentWindowController::_constrainPosition( QRectF& window ) const
{
    const QRectF& group = _displayGroup->getCoordinates();

    const qreal minX = MIN_VISIBLE_AREA_PX - window.width();
    const qreal minY = MIN_VISIBLE_AREA_PX - window.height();

    const qreal maxX = group.width() - MIN_VISIBLE_AREA_PX;
    const qreal maxY = group.height() - MIN_VISIBLE_AREA_PX;

    const QPointF position( std::max( minX, std::min( window.x(), maxX )),
                            std::max( minY, std::min( window.y(), maxY )));

    window.moveTopLeft( position );
}
开发者ID:BlueBrain,项目名称:DisplayCluster,代码行数:15,代码来源:ContentWindowController.cpp


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