本文整理汇总了C++中QRectF::moveTopRight方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::moveTopRight方法的具体用法?C++ QRectF::moveTopRight怎么用?C++ QRectF::moveTopRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::moveTopRight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()));
}
示例2: 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;
}
示例3: update
void TransformableGraphicsGuide::update()
{
if (isVisible())
{
FigureEditor::EditMode mode = editor->mode();
bool scaleMode( mode == FigureEditor::Scale );
topRightRect.setVisible(scaleMode);
topLeftRect.setVisible(scaleMode);
bottomRightRect.setVisible(scaleMode);
bottomLeftRect.setVisible(scaleMode);
if (scaleMode)
{
QPointF cen;
QPolygonF poly;
if (editor->hasSelection())
{
QGraphicsPolygonItem* item = editor->selection();
if (item == 0)
return;
cen = mapFromScene(editor->selectionTransformPos());
poly = mapFromScene(item->polygon());
}
else
{
QGraphicsPolygonItem* item = dynamic_cast<QGraphicsPolygonItem*>(parentItem());
cen = editor->triangleTransformPos();
poly = item->polygon();
}
QRectF f( poly.boundingRect() );
qreal xmax = qMax(qAbs(f.left() - cen.x()), qAbs(f.right() - cen.x()));
qreal ymax = qMax(qAbs(f.top() - cen.y()), qAbs(f.bottom() - cen.y()));
QPointF pmax(xmax, ymax);
QRectF r(pmax, -pmax);
r.moveCenter(cen);
outerRect = r;
QRectF l = parentItem()->mapRectFromScene(QRectF(QPointF(0.0, 0.0), QSizeF(10, 10)));
QPen pen( editor->guideColor() );
l.moveBottomLeft(r.topRight());
topRightRect.setPen(pen);
topRightRect.setRect(l);
l.moveBottomRight(r.topLeft());
topLeftRect.setPen(pen);
topLeftRect.setRect(l);
l.moveTopLeft(r.bottomRight());
bottomRightRect.setPen(pen);
bottomRightRect.setRect(l);
l.moveTopRight(r.bottomLeft());
bottomLeftRect.setPen(pen);
bottomLeftRect.setRect(l);
}
else if (mode == FigureEditor::Rotate)
{
QGraphicsPolygonItem* item;
QPointF cen;
QPolygonF poly;
if (editor->hasSelection())
{
item = editor->selection();
if (item == 0)
return;
cen = mapFromScene(editor->selectionTransformPos());
poly = mapFromScene(item->polygon());
}
else
{
item = dynamic_cast<QGraphicsPolygonItem*>(parentItem());
poly = item->polygon();
cen = editor->triangleTransformPos();
}
qreal rmax = 0.0;
foreach (QPointF p, poly)
{
QLineF l(p, cen);
qreal len(l.length());
if (len > rmax)
rmax = len;
}
qreal height = rmax * 2.0;
outerRect = QRectF(cen.x() - rmax, cen.y() - rmax, height, height);
}