本文整理汇总了C++中QRectF::moveTop方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::moveTop方法的具体用法?C++ QRectF::moveTop怎么用?C++ QRectF::moveTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::moveTop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doLayout
/**
* 功能
* 当前单元格子元素布局
*/
void WinDigitalDelegate::doLayout(const QStyleOptionViewItem & option, QRectF &valRect, QRectF &unitRect, QRectF &tagRect, QRectF &alarmRect, qreal &alarmSpan) const
{
/***********测量值***********/
valRect = option.rect;
valRect.setHeight(valRect.height()/3);
valRect.moveTop(valRect.bottom());
valRect.setRight(valRect.right() - valRect.width()/18- 3);
/************标记**********/
tagRect = valRect;
tagRect.moveBottom(tagRect.top());
tagRect.setTop(tagRect.top() + option.rect.height()/10);
/************单位***********/
unitRect = valRect;
unitRect.moveTop(unitRect.bottom());
unitRect.setRight(unitRect.right() - 15);
/*************报警标记**********/
alarmRect = unitRect;
alarmRect.setHeight(alarmRect.height()/3);
alarmRect.moveTop(alarmRect.bottom());
alarmRect.setLeft(alarmRect.center().x() - 4*alarmRect.height());
alarmRect.setWidth(alarmRect.height());
alarmSpan = alarmRect.width() * 2;
}
示例2: clone_marker
// The draw function for unspecified is so easy, just calculate the clone marker without a singleShape() drawing function
QPainterPath SimpleChemEPN::clone_marker() const
{
QPainterPath p_front, p_back, p_clone;
// this glyph has to be cirular:
qreal draw_width = width();
if ( height() < width()) draw_width = height();
QRectF cloneRect = QRectF( -draw_width/2, -draw_width/2, draw_width, draw_width*0.7 );
if (this->multimer == true) {
QPainterPath p_front2, p_back2;
p_clone.setFillRule(Qt::WindingFill);
p_front.addEllipse( -draw_width/2, -draw_width/2, draw_width-GLYPH_PADDING, draw_width-GLYPH_PADDING );
p_back.addRect(cloneRect);
p_clone.addPath(p_front.subtracted(p_back));
cloneRect.moveTop( -draw_width/2+GLYPH_PADDING );
p_front2.addEllipse( -draw_width/2+GLYPH_PADDING, -draw_width/2+GLYPH_PADDING, draw_width-GLYPH_PADDING, draw_width-GLYPH_PADDING );
p_back2.addRect(cloneRect);
p_clone.addPath(p_front2.subtracted(p_back2));
}
else {
p_front.addEllipse( -draw_width/2, -draw_width/2, draw_width, draw_width );
p_back.addRect(cloneRect);
p_clone = p_front.subtracted(p_back);
}
return p_clone;
}
示例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: clone_marker
QPainterPath ComplexEPN::clone_marker() const
{
QPainterPath p_clone, p_front, p_back;
int indent = 10; // indent on the width/height for the cut-off corners
QRectF cloneRect = QRectF( -width()/2, -height()/2, width(), height()*0.7 );
if (this->multimer == true) {
p_front = ComplexEPN::frontMultimerShape( width(), height(), indent );
p_back.addRect(cloneRect);
p_clone = p_front.subtracted(p_back);
QPainterPath p_front2, p_back2;
p_front2 = ComplexEPN::backMultimerShape( width(), height(), indent );
cloneRect.moveTop( -height()/2+GLYPH_PADDING );
p_back2.addRect(cloneRect);
p_clone.setFillRule(Qt::WindingFill);
p_clone.addPath(p_front2.subtracted(p_back2));
}
else {
p_front = ComplexEPN::singleShape( width(), height(), indent );
p_back.addRect(cloneRect);
p_clone = p_front.subtracted(p_back);
}
return p_clone;
}
示例5: 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();
}
示例6: 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();
}
示例7: paint
void NodeInspector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
const auto r = boundingRect().adjusted(border, border, -border, -border);
if (glow)
{
painter->setBrush(Qt::NoBrush);
painter->setPen(QPen(QColor(255, 255, 255, Colors::base02.red()), 20));
painter->drawRoundedRect(r, 8, 8);
}
painter->setBrush(Colors::base01);
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(r, 8, 8);
painter->setBrush(Colors::base03);
QRectF br = title_row->boundingRect();
br.setWidth(r.width());
br.setHeight(br.height() + 2);
painter->drawRoundedRect(br, 8, 8);
br.setHeight(br.height()/2);
br.moveTop(br.height());
painter->drawRect(br);
painter->setBrush(Qt::NoBrush);
if (isSelected())
painter->setPen(QPen(Colors::base05, 2));
else
painter->setPen(QPen(Colors::base03, 2));
painter->drawRoundedRect(r, 8, 8);
}
示例8: 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);
}
示例9: PaintPage
void TextDocumentAdapter::PaintPage (QPainter *painter, int page)
{
const auto& size = Doc_->pageSize ();
QRectF rect (QPointF (0, 0), size);
rect.moveTop (rect.height () * page);
Doc_->drawContents (painter, rect);
}
示例10: onYChanged
void ShapeSideBar::onYChanged(int y)
{
if (d->rectLayer)
{
QRectF rect = d->rectLayer->rect();
rect.moveTop(y);
layerScene()->setLayerProperty(d->rectLayer, rect, RoleRect, tr("Change Rectangle y"));
}
}
示例11: 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);
}
示例12: 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); }
}
示例13: 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);
}
示例14: 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());
}
示例15:
QList<QRectF> Mode4::locate()
{
QList<QRectF> results;
if (rect.height() > 360){
return results;
}
QSize size = ARender::instance()->getActualSize();
QRectF init = rect;
init.moveCenter(QPointF(size.width() / 2.0, 0));
init.moveBottom(size.height()*(Config::getValue("/Danmaku/Protect", false) ? 0.85 : 1));
int stp = Config::getValue("/Danmaku/Grating", 10);
for (int height = init.top(); height >= 0; height -= stp){
init.moveTop(height);
results.append(init);
}
return results;
}