本文整理汇总了C++中QRectF::moveLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::moveLeft方法的具体用法?C++ QRectF::moveLeft怎么用?C++ QRectF::moveLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::moveLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: advance
void Player::advance(int step) {
if (step == 0) {
// ignore that we are _about_ to advance
return;
}
if (m_left){
this->setRect(this->rect().translated(QPointF(-10,0)));
}
if (m_right){
this->setRect(this->rect().translated(QPointF(10,0)));
}
if (this->rect().right() > scene()->width()){
qWarning("hit right");
QRectF newRec = this->rect();
newRec.moveLeft(scene()->width() - this->rect().width());
this->setRect(newRec);
}
if (this->rect().left() < 0){
qWarning("hit right");
QRectF newRec = this->rect();
newRec.moveLeft(0);
this->setRect(newRec);
}
}
示例2: QLineF
void
FormCheckBox::draw( QPainter * painter, const QPen & pen, const QFont & font,
const QRectF & rect, qreal width, bool isChecked, const QString & text )
{
painter->setPen( pen );
painter->drawRect( rect );
if( isChecked )
{
painter->drawLine( QLineF( rect.topLeft().x() + 4.0,
rect.topLeft().y() + rect.height() / 2.0,
rect.topLeft().x() + rect.width() / 2.0,
rect.bottomLeft().y() - 4.0 ) );
painter->drawLine( QLineF(
rect.topLeft().x() + rect.width() / 2.0,
rect.bottomLeft().y() - 4.0,
rect.topRight().x() - 4.0,
rect.topRight().y() + 4.0 ) );
}
painter->setFont( font );
QRectF r = rect;
r.setRight( rect.x() + width );
r.moveLeft( rect.x() + rect.height() + 4.0 );
painter->drawText( r, Qt::AlignLeft | Qt::AlignVCenter, text );
}
示例3: printAreaMoved
// slot
void PrintWidget::printAreaMoved()
{
QRectF area = map_printer->getPrintArea();
area.moveLeft(left_edit->value());
area.moveTop(-top_edit->value()); // Flip sign!
map_printer->setPrintArea(area);
}
示例4: mouseMoveEvent
void EditorView::mouseMoveEvent(QMouseEvent *event)
{
if (mWheelPressed) {
if (mMouseOldPosition != QPointF()) {
QRectF rect = sceneRect();
qreal dx = (event->posF().x() - mMouseOldPosition.x());
qreal dy = (event->posF().y() - mMouseOldPosition.y());
rect.moveLeft(rect.left() - dx);
rect.moveTop(rect.top() - dy);
setSceneRect(rect);
}
mMouseOldPosition = event->posF();
}
QGraphicsView::mouseMoveEvent(event);
if (event->buttons() & Qt::RightButton) {
setDragMode(NoDrag);
} else {
if (event->buttons() & Qt::LeftButton ) {
UML::EdgeElement *newEdgeEl = dynamic_cast<UML::EdgeElement *>(itemAt(event->pos()));
if (newEdgeEl == NULL) {
setDragMode(RubberBandDrag);
} else {
if (newEdgeEl->isBreakPointPressed()) {
newEdgeEl->breakPointUnpressed();
setDragMode(NoDrag);
}
}
}
}
if (mScene->getNeedDrawGrid())
mScene->invalidate();
}
示例5: mouseMoveEvent
void EditorView::mouseMoveEvent(QMouseEvent *event)
{
if (mWheelPressed) {
if (mMouseOldPosition != QPointF()) {
QRectF rect = sceneRect();
qreal dx = (event->localPos().x() - mMouseOldPosition.x());
qreal dy = (event->localPos().y() - mMouseOldPosition.y());
rect.moveLeft(rect.left() - dx);
rect.moveTop(rect.top() - dy);
setSceneRect(rect);
translate(dx, dy);
}
mMouseOldPosition = event->localPos();
}
QGraphicsView::mouseMoveEvent(event);
if (event->buttons() & Qt::RightButton) {
setDragMode(NoDrag);
} else {
if ((event->buttons() & Qt::LeftButton) && (event->modifiers() & Qt::ControlModifier)) {
setDragMode(RubberBandDrag);
mScene->itemSelectUpdate();
/*} else if ((event->buttons() & Qt::LeftButton) && (event->modifiers() & Qt::ShiftModifier)) {
setDragMode(ScrollHandDrag); // (see #615)
mScene->itemSelectUpdate();*/
} else if (event->buttons() & Qt::LeftButton ) {
EdgeElement *newEdgeEl = dynamic_cast<EdgeElement *>(itemAt(event->pos()));
if (newEdgeEl && newEdgeEl->isBreakPointPressed()) {
newEdgeEl->breakPointUnpressed();
setDragMode(NoDrag);
}
}
}
if (mScene->getNeedDrawGrid())
mScene->invalidate();
}
示例6: itemChange
QVariant PixmapItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == ItemPositionChange)
{
// value is the new position.
QPointF newPos = value.toPointF();
QRectF rect = parentItem()->boundingRect();
rect.moveLeft(boundingRect().width()*3/4*-1);
rect.setWidth(rect.width() + boundingRect().width()*2/4 );
rect.moveTop(boundingRect().height()*3/4*-1);
rect.setHeight(rect.height() + boundingRect().height()*2/4 );
CardItem *card = qgraphicsitem_cast<CardItem *>(parentItem());
if (!rect.contains(newPos))
{
// Keep the item inside the scene rect.
int newX = (int)qMin(rect.right(), qMax(newPos.x(), rect.left()));
int newY = (int)qMin(rect.bottom(), qMax(newPos.y(), rect.top()));
if(card->isAlign())
{
int gridSize = card->getGridSize();
newX = (newX/(10*gridSize))*(10*gridSize);
newY = (newY/(10*gridSize))*(10*gridSize);
}
newPos.setX(newX);
newPos.setY(newY);
return newPos;
}
else
{
int newX = newPos.x();
int newY = newPos.y();
if(card->isAlign())
{
int gridSize = card->getGridSize();
newX = newPos.x()/(10*gridSize);
newX = newX * (10*gridSize);
newY = newPos.y()/(10*gridSize);
newY = newY*(10*gridSize);
}
newPos.setX(newX);
newPos.setY(newY);
return newPos;
}
}
return QGraphicsItem::itemChange(change, value);
}
示例7: onXChanged
void ShapeSideBar::onXChanged(int x)
{
if (d->rectLayer)
{
QRectF rect = d->rectLayer->rect();
rect.moveLeft(x);
layerScene()->setLayerProperty(d->rectLayer, rect, RoleRect, tr("Change Rectangle x"));
}
}
示例8: relayoutExtender
void relayoutExtender()
{
if (!m_extenders.contains(q->scene())
|| !m_extenders[q->scene()]
|| q != m_extenders[q->scene()]->parentItem()) return;
QRectF geometry = QRectF(QPointF(0, 0), q->size());
// extender()->borders = Plasma::FrameSvg::AllBorders;
borders = Plasma::FrameSvg::AllBorders;
switch (extenderPosition) {
case TopExtender:
geometry.setHeight(EXTENDER_SIZE);
geometry.moveTop(- EXTENDER_SIZE);
// borders &= ~ Plasma::FrameSvg::TopBorder;
// extender()->borders &= ~ Plasma::FrameSvg::BottomBorder;
break;
case BottomExtender:
geometry.moveTop(geometry.bottom());
geometry.setHeight(EXTENDER_SIZE);
// borders &= ~ Plasma::FrameSvg::BottomBorder;
// extender()->borders &= ~ Plasma::FrameSvg::TopBorder;
break;
case LeftExtender:
geometry.setWidth(EXTENDER_SIZE);
geometry.moveLeft(- EXTENDER_SIZE);
// borders &= ~ Plasma::FrameSvg::LeftBorder;
// extender()->borders &= ~ Plasma::FrameSvg::RightBorder;
break;
case RightExtender:
geometry.moveLeft(geometry.right());
geometry.setWidth(EXTENDER_SIZE);
// borders &= ~ Plasma::FrameSvg::RightBorder;
// extender()->borders &= ~ Plasma::FrameSvg::LeftBorder;
break;
case NoExtender:
break;
}
extender()->setGeometry(geometry);
extender()->setPreferredSize(geometry.size());
// qreal left, top, right, bottom;
// q->getContentsMargins(&left, &top, &right, &bottom);
}
示例9: back
// QtPluginIconPalletTool Interface
void
dmz::QtPluginIconPalletTool::_add_type (const ObjectType &Type) {
const String IconResource = config_to_string (
get_plugin_name () + ".resource",
Type.get_config());
const String IconName = _rc.find_file (IconResource);
if (IconName) {
const String Name = Type.get_name ();
if (Name) {
QImage back (
(int)_iconExtent,
(int)_iconExtent,
QImage::Format_ARGB32_Premultiplied);
QPainter painter (&back);
painter.setCompositionMode (QPainter::CompositionMode_Source);
painter.fillRect (back.rect (), Qt::transparent);
painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
QSvgRenderer qsr (QString (IconName.get_buffer ()));
QRectF size = qsr.viewBoxF ();
qreal width = size.width ();
qreal height = size.height ();
qreal scale = (width > height) ? width : height;
if (scale <= 0.0f) { scale = 1.0f; }
scale = _iconExtent / scale;
width *= scale;
height *= scale;
size.setWidth (width);
size.setHeight (height);
if (height < _iconExtent) { size.moveTop ((_iconExtent - height) * 0.5f); }
if (width < _iconExtent) { size.moveLeft ((_iconExtent - width) * 0.5f); }
qsr.render (&painter, size);
painter.end ();
QIcon icon;
icon.addPixmap (QPixmap::fromImage (back));
QStandardItem *item = new QStandardItem (icon, Name.get_buffer ());
item->setEditable (false);
_model.appendRow (item);
}
}
else if (IconResource) {
_log.error << "Unable to find icon resource: " << IconResource
<< " for object type: " << Type.get_name () << endl;
}
RuntimeIterator it;
ObjectType next;
while (Type.get_next_child (it, next)) { _add_type (next); }
}
示例10: setCenter
void GraphNode::setCenter(const QPointF& pt)
{
cx = pt.x();
cy = pt.y();
QRectF newRect = rect();
newRect.moveLeft(cx - r);
newRect.moveTop(cy - r);
setRect(newRect);
}
示例11: sizeby
foreach(QReportWidgetBase *widget, _selectedWidgets) {
QRectF widgetRect = _widgetRects[widget];
QSizeF sizeby(
rc.width() / selectionRect.width(),
rc.height() / selectionRect.height());
widgetRect.moveTop(widgetRect.top() - selectionRect.top());
widgetRect.moveLeft(widgetRect.left() - selectionRect.left());
widgetRect.setTop(widgetRect.top() *sizeby.height());
widgetRect.setBottom(widgetRect.bottom() *sizeby.height());
widgetRect.setLeft(widgetRect.left() *sizeby.width());
widgetRect.setRight(widgetRect.right() *sizeby.width());
widgetRect.moveTop(widgetRect.top() + rc.top());
widgetRect.moveLeft(widgetRect.left() + rc.left());
widgetRect.moveTopLeft(widget->parentItem()->mapFromScene(widgetRect.topLeft()));
widget->setPos(widgetRect.topLeft());
widget->setSize(widgetRect.width(), widgetRect.height());
}
示例12:
QList<QRectF> Mode1::locate()
{
QList<QRectF> results;
if (rect.height() > 360){
return results;
}
QSize size = ARender::instance()->getActualSize();
QRectF init = rect;
init.moveLeft(size.width());
int end = size.height()*(Config::getValue("/Danmaku/Protect", false) ? 0.85 : 1) - rect.height();
int stp = Config::getValue("/Danmaku/Grating", 10);
for (int height = 0; height <= end; height += stp){
init.moveTop(height);
results.append(init);
}
return results;
}
示例13: viewportRect
//-----------------------------------------------------------------------------
QRectF vktraceviewer_QTimelineView::viewportRect(const QModelIndex &index) const
{
QRectF rectf = itemRect(index);
if (rectf.isValid())
{
rectf.moveLeft( rectf.left() * m_zoomFactor);
rectf.setWidth( rectf.width() * m_zoomFactor);
rectf.adjust(-horizontalScrollBar()->value(), 0,
-horizontalScrollBar()->value(), 0);
// the margin is added last so that it is NOT scaled
rectf.adjust(m_margin, 0,
m_margin, 0);
}
return rectf;
}
示例14: __drawWaterfall
void QWaterfallWidget::__drawWaterfall(QPainter &painter)
{
float widthF = (float)rect().width() / m_columns;
float heightF = (float)rect().height() / m_rows;
float posX = 0.0, posY = 0.0;
QRectF rectF = QRectF(0.0, 0.0, widthF, heightF);
painter.setPen(Qt::NoPen);
int temp;
for(int i = 0; i < m_rows; i++) {
rectF.moveTop(posY);
posX = 0.0;
for(int j = 0; j < m_columns; j++) {
rectF.moveLeft(posX);
temp = m_data[i][j]*1023;
temp = (temp > 1023) ? 1023 : temp;
temp = (temp < 0) ? 0 : temp;
painter.setBrush(v_lookupTable[temp]);
painter.drawRect(rectF);
posX += widthF;
}
posY += heightF;
}
}
示例15: evalItemRect
//.........这里部分代码省略.........
bool ok = false;
double ddWidth = mDataDefinedProperties.valueAsDouble( QgsComposerObject::ItemWidth, *evalContext, 0, &ok );
//evaulate width and height first, since they may affect position if non-top-left reference point set
if ( ok )
{
result.setWidth( ddWidth );
}
double ddHeight = mDataDefinedProperties.valueAsDouble( QgsComposerObject::ItemHeight, *evalContext, 0, &ok );
if ( ok )
{
result.setHeight( ddHeight );
}
double x = result.left();
//initially adjust for position mode to get x coordinate
if ( !resizeOnly )
{
//adjust x-coordinate if placement is not done to a left point
if ( mLastUsedPositionMode == UpperMiddle || mLastUsedPositionMode == Middle || mLastUsedPositionMode == LowerMiddle )
{
x += newRect.width() / 2.0;
}
else if ( mLastUsedPositionMode == UpperRight || mLastUsedPositionMode == MiddleRight || mLastUsedPositionMode == LowerRight )
{
x += newRect.width();
}
}
else
{
if ( mLastUsedPositionMode == UpperMiddle || mLastUsedPositionMode == Middle || mLastUsedPositionMode == LowerMiddle )
{
x += rect().width() / 2.0;
}
else if ( mLastUsedPositionMode == UpperRight || mLastUsedPositionMode == MiddleRight || mLastUsedPositionMode == LowerRight )
{
x += rect().width();
}
}
double ddPosX = mDataDefinedProperties.valueAsDouble( QgsComposerObject::PositionX, *evalContext, 0.0, &ok );
if ( ok )
{
x = ddPosX;
}
double y = result.top();
//initially adjust for position mode to get y coordinate
if ( !resizeOnly )
{
//adjust y-coordinate if placement is not done to an upper point
if ( mLastUsedPositionMode == MiddleLeft || mLastUsedPositionMode == Middle || mLastUsedPositionMode == MiddleRight )
{
y += newRect.height() / 2.0;
}
else if ( mLastUsedPositionMode == LowerLeft || mLastUsedPositionMode == LowerMiddle || mLastUsedPositionMode == LowerRight )
{
y += newRect.height();
}
}
else
{
if ( mLastUsedPositionMode == MiddleLeft || mLastUsedPositionMode == Middle || mLastUsedPositionMode == MiddleRight )
{
y += rect().height() / 2.0;
}
else if ( mLastUsedPositionMode == LowerLeft || mLastUsedPositionMode == LowerMiddle || mLastUsedPositionMode == LowerRight )
{
y += rect().height();
}
}
double ddPosY = mDataDefinedProperties.valueAsDouble( QgsComposerObject::PositionY, *evalContext, 0, &ok );
if ( ok )
{
y = ddPosY;
}
//adjust x-coordinate if placement is not done to a left point
if ( mLastUsedPositionMode == UpperMiddle || mLastUsedPositionMode == Middle || mLastUsedPositionMode == LowerMiddle )
{
x -= result.width() / 2.0;
}
else if ( mLastUsedPositionMode == UpperRight || mLastUsedPositionMode == MiddleRight || mLastUsedPositionMode == LowerRight )
{
x -= result.width();
}
//adjust y-coordinate if placement is not done to an upper point
if ( mLastUsedPositionMode == MiddleLeft || mLastUsedPositionMode == Middle || mLastUsedPositionMode == MiddleRight )
{
y -= result.height() / 2.0;
}
else if ( mLastUsedPositionMode == LowerLeft || mLastUsedPositionMode == LowerMiddle || mLastUsedPositionMode == LowerRight )
{
y -= result.height();
}
result.moveLeft( x );
result.moveTop( y );
return result;
}