本文整理汇总了C++中QRectF::moveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::moveTo方法的具体用法?C++ QRectF::moveTo怎么用?C++ QRectF::moveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showFpsCounter
void MScenePrivate::showFpsCounter(QPainter *painter, float fps)
{
Q_Q(MScene);
QString display = QString("FPS: %1").arg((int)(fps + 0.5f));
/* Draw a simple FPS counter in the lower right corner */
static QRectF fpsRect(0, 0, FpsBoxSize.width(), FpsBoxSize.height());
if (!q->views().isEmpty()) {
MApplicationWindow *window = qobject_cast<MApplicationWindow *>(q->views().at(0));
if (window) {
if (manager && manager->orientation() == M::Portrait)
fpsRect.moveTo(QPointF(window->visibleSceneSize().height() - FpsBoxSize.width(),
window->visibleSceneSize().width() - FpsBoxSize.height()));
else
fpsRect.moveTo(QPointF(window->visibleSceneSize().width() - FpsBoxSize.width(),
window->visibleSceneSize().height() - FpsBoxSize.height()));
}
}
painter->fillRect(fpsRect, fpsBackgroundBrush);
painter->setPen(FpsTextColor);
painter->setFont(FpsFont);
painter->drawText(fpsRect,
Qt::AlignCenter,
display);
}
示例2: ResizeCommand
ResizeCommand *ResizeCommand::create(const NodeElement * const element
, const QRectF &newContents, const QPointF &newPos
, const QRectF &oldContents, const QPointF &oldPos)
{
QRectF newContentsAndPos = newContents;
newContentsAndPos.moveTo(newPos);
QRectF oldContentsAndPos = oldContents;
oldContentsAndPos.moveTo(oldPos);
return new ResizeCommand(dynamic_cast<EditorViewScene *>(element->scene())
, element->id(), oldContentsAndPos, newContentsAndPos);
}
示例3: textCursor
void
FormText::clearFormat()
{
QTextCursor c = textCursor();
if( c.hasSelection() )
{
QTextCharFormat fmt = c.charFormat();
fmt.setFontUnderline( false );
fmt.setFontItalic( false );
fmt.setFontWeight( QFont::Normal );
fmt.setFontPointSize( 10 );
textCursor().setCharFormat( fmt );
}
else
{
QFont f = font();
f.setUnderline( false );
f.setItalic( false );
f.setWeight( QFont::Normal );
f.setPointSize( 10.0 );
setFont( f );
}
QRectF r = boundingRect();
r.moveTo( pos() );
d->m_proxy->setRect( r );
}
示例4: updateProxyGeometryFromWidget
/*!
\internal
*/
void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget()
{
Q_Q(QGraphicsProxyWidget);
if (!widget)
return;
QRectF widgetGeometry = widget->geometry();
QWidget *parentWidget = widget->parentWidget();
if (widget->isWindow()) {
QGraphicsProxyWidget *proxyParent = 0;
if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
// Nested window proxy (e.g., combobox popup), map widget to the
// parent widget's global coordinates, and map that to the parent
// proxy's child coordinates.
widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
+ parentWidget->mapFromGlobal(widget->pos()));
}
}
// Adjust to size hint if the widget has never been resized.
if (!widget->size().isValid())
widgetGeometry.setSize(widget->sizeHint());
// Assign new geometry.
posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
q->setGeometry(widgetGeometry);
posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
}
示例5: containsSceneSpace
bool ShaderNodeUI::containsSceneSpace(const QPointF& point) const
{
QRectF localRect = boundingRect();
localRect.moveTo(pos().x(), pos().y());
return localRect.contains(point);
}
示例6: addTeteToMinMax
void ChatNode::addTeteToMinMax(Tete* tete,
float* min_x, float* min_y,
float* max_x, float* max_y) {
//return;
if(tete == NULL)
return;
if(tete->tete_node() == NULL)
return;
QRectF local_bound = tete->tete_node()->boundingRect();
QRectF bound = local_bound;
bound.moveTo(tete->tete_node()->pos());
bound.translate(-local_bound.width()/2,-local_bound.height()/2);
//std::cerr << bound.topLeft().y() << " " << *min_y << std::endl;
if(bound.topLeft().x() < *min_x)
*min_x = bound.topLeft().x();
if(bound.topLeft().y() < *min_y)
*min_y = bound.topLeft().y();
if(bound.bottomRight().x() > *max_x)
*max_x = bound.bottomRight().x();
if(bound.bottomRight().y() > *max_y)
*max_y = bound.bottomRight().y();
}
示例7: updateAllTetesRect
void ChatNode::updateAllTetesRect(){
std::vector<Tete*> tetes = chat_->tetes();
if(tetes.empty()){
all_tetes_rect_ = QRectF(-1, -1, 2, 2);
return;
}
TeteNode* first_node = NULL;
// Find the first non-null node
for(unsigned int i = 0u; first_node == NULL; i++){
first_node = tetes[i]->tete_node();
}
QRectF local_bound = first_node->boundingRect();
QRectF bound = local_bound;
bound.moveTo(first_node->pos());
// Translate more due to text
bound.translate(-local_bound.width()/2,-local_bound.height()/2);
float min_x = bound.topLeft().x();
float min_y = bound.topLeft().y();
float max_x = bound.bottomRight().x();
float max_y = bound.bottomRight().y();
for(std::vector<Tete*>::const_iterator it = tetes.begin(); it != tetes.end(); ++it){
addTeteToMinMax(*it, &min_x, &min_y, &max_x, &max_y);
}
all_tetes_rect_ = QRectF(QPointF(min_x, min_y),
QPointF(max_x, max_y)).normalized();
}
示例8: rectToScene
QRectF KWidget::rectToScene() const
{
QRectF rt = rect();
QPointF pt = mapToScene(rt.topLeft());
rt.moveTo(pt);
return rt;
}
示例9: paint
void AnchorIndicatorGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */)
{
painter->save();
QPen linePen(QColor(0, 0, 0, 150));
linePen.setDashPattern(QVector<double>() << 3. << 2.);
painter->setPen(linePen);
painter->drawLine(m_startPoint, m_firstControlPoint);
painter->drawLine(m_firstControlPoint, m_secondControlPoint);
painter->drawLine(m_secondControlPoint, m_endPoint);
linePen.setColor(QColor(255, 255, 255, 150));
linePen.setDashPattern(QVector<double>() << 2. << 3.);
linePen.setDashOffset(2.);
painter->setPen(linePen);
painter->drawLine(m_startPoint, m_firstControlPoint);
painter->drawLine(m_firstControlPoint, m_secondControlPoint);
painter->drawLine(m_secondControlPoint, m_endPoint);
static QRectF bumpRectangle(0., 0., 8., 8.);
painter->setPen(QPen(QColor(0, 255 , 0), 2));
painter->drawLine(m_sourceAnchorLineFirstPoint, m_sourceAnchorLineSecondPoint);
bumpRectangle.moveTo(m_startPoint.x() - 4., m_startPoint.y() - 4.);
painter->setBrush(painter->pen().color());
painter->setRenderHint(QPainter::Antialiasing, true);
painter->drawChord(bumpRectangle, startAngleForAnchorLine(m_sourceAnchorLineType), 180 * 16);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(QPen(QColor(0, 0 , 255), 2));
painter->drawLine(m_targetAnchorLineFirstPoint, m_targetAnchorLineSecondPoint);
bumpRectangle.moveTo(m_endPoint.x() - 4., m_endPoint.y() - 4.);
painter->setBrush(painter->pen().color());
painter->setRenderHint(QPainter::Antialiasing, true);
painter->drawChord(bumpRectangle, startAngleForAnchorLine(m_targetAnchorLineType), 180 * 16);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->restore();
}
示例10: rectToView
QRectF KWidget::rectToView() const
{
QGraphicsView *gview = view();
QRectF rt = rect();
QPointF pt = mapToScene(rt.topLeft());
QPoint vpt = gview->mapFromScene(pt);
rt.moveTo(vpt);
return rt;
}
示例11: tick
void Simulation::tick()
{
qreal elapsed_secs = m_time.elapsed() * 1000.0;
Q_FOREACH(QGraphicsItem* item, childItems()) {
Particle* p = qobject_cast<Particle*>(item);
if (p != 0) {
p->move(elapsed_secs);
QRectF bounds = p->boundingRect();
bounds.moveTo(p->pos());
qDebug() << "Scheduling update for" << bounds;
update(bounds);
}
}
示例12: resize
void ResizeHandler::resize(QRectF newContents, QPointF newPos, bool needResizeParent) const
{
newContents.moveTo(0, 0);
sortChildrenIfNeeded();
gripeIfMinimizesToChildrenContainer(newContents);
if (!mTargetNode->isFolded()) {
resizeAccordingToChildren(newContents, newPos);
}
normalizeSize(newContents);
newContents.moveTo(newPos);
mTargetNode->setGeometry(newContents);
mTargetNode->storeGeometry();
mTargetNode->setPos(newPos);
if (needResizeParent) {
resizeParent();
}
mTargetNode->updateLabels();
}
示例13: QPointF
NodeElement *CopyHandler::clone(bool toCursorPos, bool searchForParents)
{
EditorViewScene *evscene = dynamic_cast<EditorViewScene *>(mNode.scene());
qReal::Id typeId = mNode.id().type();
qReal::Id resultId = evscene->createElement(typeId.toString(), QPointF(), searchForParents);
NodeElement *result = dynamic_cast<NodeElement *>(evscene->getElem(resultId));
copyProperties(*result, mNode);
copyChildren(*result, mNode);
QRectF contents = mNode.contentsRect();
if (toCursorPos) {
contents.moveTo(evscene->getMousePos());
result->setGeometry(contents);
result->storeGeometry();
}
else {
contents.moveTo(mNode.pos());
result->setGeometry(contents);
}
return result;
}
示例14: dizzy
void QgsStatusBarCoordinatesWidget::dizzy()
{
if ( !mMapCanvas )
{
return;
}
// constants should go to options so that people can customize them to their taste
int d = 10; // max. translational dizziness offset
int r = 4; // max. rotational dizzines angle
QRectF rect = mMapCanvas->sceneRect();
if ( rect.x() < -d || rect.x() > d || rect.y() < -d || rect.y() > d )
return; // do not affect panning
rect.moveTo(( qrand() % ( 2 * d ) ) - d, ( qrand() % ( 2 * d ) ) - d );
mMapCanvas->setSceneRect( rect );
QTransform matrix;
matrix.rotate(( qrand() % ( 2 * r ) ) - r );
mMapCanvas->setTransform( matrix );
}
示例15: Paint
void CCJKShapeLine::Paint(QPainter * painter)
{
CJK_D(CCJKShapeLine);
BeginPaint(painter);
painter->drawLine(d->line);
if (!d->sText.isEmpty())
{
QPointF tmpPoint = d->line.pointAt(0.5);
QFontMetrics fontMetrics(d->font);
QRectF txtRect = fontMetrics.boundingRect(d->sText);
txtRect.moveTo(tmpPoint);
txtRect.translate(-txtRect.width() / 2, -txtRect.height() / 2);
QPen tmpPen = d->pen;
tmpPen.setColor(d->textColor);
painter->setPen(tmpPen);
painter->drawText(txtRect, d->sText);
}
DrawArrow(painter, d->line);
EndPaint(painter);
}