本文整理汇总了C++中QRectF::setTopLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setTopLeft方法的具体用法?C++ QRectF::setTopLeft怎么用?C++ QRectF::setTopLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setTopLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void WidgetStyle::WidgetScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
if(m_mouseButton == Qt::LeftButton)
{
QRectF rect = m_rectItem->rect();
QPointF point = event->scenePos();
if(point.x() >= m_topLeftRect.x() && point.y() >= m_topLeftRect.y())
{
rect.setTopLeft(m_topLeftRect);
rect.setBottomRight(point);
}
else if(point.x() >= m_topLeftRect.x() && point.y() <= m_topLeftRect.y())
{
rect.setBottomLeft(m_topLeftRect);
rect.setTopRight(point);
}
else if(point.x() <= m_topLeftRect.x() && point.y() >= m_topLeftRect.y())
{
rect.setTopRight(m_topLeftRect);
rect.setBottomLeft(point);
}
else if(point.x() <= m_topLeftRect.x() && point.y() <= m_topLeftRect.y())
{
rect.setBottomRight(m_topLeftRect);
rect.setTopLeft(point);
}
m_rectItem->setRect(rect);
m_wgtStyle->distinguishRect(rect);
}
QGraphicsScene::mouseMoveEvent(event);
}
示例2: paint
void paint(QPainter * painter,
const QStyleOptionGraphicsItem * option, QWidget * widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// BasicWidget::paint(painter, option, widget);
if (iconInSvg().isValid()) {
QRectF iconRect = QRectF(QPointF(), iconSize());
QSizeF sizeDiff = size() - iconRect.size();
iconRect.setTopLeft(QPointF(sizeDiff.width() / 2, sizeDiff.height() / 2));
if (animate) {
iconInSvg().paint(painter,
iconRect.left(),
iconRect.top(),
"frame" + QString::number(frame));
} else {
iconInSvg().paint(painter,
iconRect.left(),
iconRect.top(),
"frame" + QString::number(
(frame > 0) ? frameCount : 0
));
}
}
}
示例3: eraseRegionObjectGroup
void eraseRegionObjectGroup(MapDocument *mapDocument,
ObjectGroup *layer,
const QRegion &where)
{
QUndoStack *undo = mapDocument->undoStack();
const auto objects = layer->objects();
for (MapObject *obj : objects) {
// TODO: we are checking bounds, which is only correct for rectangles and
// tile objects. polygons and polylines are not covered correctly by this
// erase method (we are in fact deleting too many objects)
// TODO2: toAlignedRect may even break rects.
// Convert the boundary of the object into tile space
const QRectF objBounds = obj->boundsUseTile();
QPointF tl = mapDocument->renderer()->pixelToTileCoords(objBounds.topLeft());
QPointF tr = mapDocument->renderer()->pixelToTileCoords(objBounds.topRight());
QPointF br = mapDocument->renderer()->pixelToTileCoords(objBounds.bottomRight());
QPointF bl = mapDocument->renderer()->pixelToTileCoords(objBounds.bottomLeft());
QRectF objInTileSpace;
objInTileSpace.setTopLeft(tl);
objInTileSpace.setTopRight(tr);
objInTileSpace.setBottomRight(br);
objInTileSpace.setBottomLeft(bl);
const QRect objAlignedRect = objInTileSpace.toAlignedRect();
if (where.intersects(objAlignedRect))
undo->push(new RemoveMapObject(mapDocument, obj));
}
}
示例4: mapFromItem
void core::Connector::setEndObject(GraphicObject *end)
{
if(!end) return;
endObject = end;
// qDebug() << currentMousePos;
//we use currentMousePos instead internal currentMousePos from "end" object due update mouse position problems
//there are conflicts when moving mouse so using this currentMousePos ensures mouse pos is always updated
// qDebug() << portRect;
endPoint = mapFromItem(end, end->getCurrentPortPos(mapToItem(end, currentMousePos)));
isBuildingConector = false;
// qDebug() << portCenter;
QRectF container = getContainerRect();
if(currentMousePos.x() < 0 && currentMousePos.y() < 0){
container.setTopLeft(endPoint );
}else if(currentMousePos.x() < 0 && currentMousePos.y() >= 0){
container.setBottomLeft(endPoint );
}else if(currentMousePos.x() >= 0 && currentMousePos.y() < 0){
container.setTopRight(endPoint );
}else if(currentMousePos.x() >= 0 && currentMousePos.y() >= 0){
container.setBottomRight(endPoint );
}else{
container= QRectF(0, 0, 0, 0);
}
setContainerRect(container);
}
示例5: setRect
void QgsMapCanvasItem::setRect( const QgsRectangle& rect, bool resetRotation )
{
mRect = rect;
//updatePosition();
QRectF r; // empty rect by default
if ( !mRect.isEmpty() )
{
// rect encodes origin of the item (xMin,yMax from map to canvas units)
// and size (rect size / map units per pixel)
r.setTopLeft( toCanvasCoordinates( QPointF( mRect.xMinimum(), mRect.yMaximum() ) ) );
const QgsMapToPixel* m2p = mMapCanvas->getCoordinateTransform();
double res = m2p->mapUnitsPerPixel();
r.setSize( QSizeF( mRect.width() / res, mRect.height() / res ) );
}
// set position in canvas where the item will have coordinate (0,0)
prepareGeometryChange();
setPos( r.topLeft() );
mItemSize = QSizeF( r.width() + 2, r.height() + 2 );
if ( resetRotation )
{
mRectRotation = mMapCanvas->rotation();
setRotation( 0 );
}
// QgsDebugMsg(QString("[%1,%2]-[%3x%4]").arg((int) r.left()).arg((int) r.top()).arg((int) r.width()).arg((int) r.height()));
update();
}
示例6: mouseMoveEvent
void BlurItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsRectItem::mouseMoveEvent(event);
const QPointF pos = event->scenePos();
QRectF r;
r.setTopLeft(m_point);
r.setBottomRight(event->scenePos());
if (r.width() < 0) {
r.setLeft(pos.x());
r.setRight(m_point.x());
}
if (r.height() < 0) {
r.setTop(pos.y());
r.setBottom(m_point.y());
}
r = r.intersected(m_item->scene()->sceneRect());
setRect(r);
setSelected(true);
m_item->setOffset(r.topLeft());
reload(m_pixmap);
}
示例7: boundingRect
QRectF coils::boundingRect() const
{
QRectF rect;
rect.setTopLeft(QPointF(-15,-15));
rect.setBottomRight(QPointF(15,15));
return rect;
}
示例8: paintColorScale
void ColorScaleWidget::paintColorScale(QPainter& painter, const QRect& rect) {
painter.setPen(Qt::NoPen);
map<float, Color> colorMap = colorScale->getColorMap();
if (colorScale->isGradient()) {
QPoint start;
QPoint stop;
if (orientation == Qt::Horizontal) {
start = QPoint(rect.left(), rect.center().y());
stop = QPoint(rect.right(), rect.center().y());
}
else {
start = QPoint(rect.center().x(), rect.bottom());
stop = QPoint(rect.center().x(), rect.top());
}
QLinearGradient qLinearGradient(start, stop);
for (map<float, Color>::iterator it = colorMap.begin(); it != colorMap.end(); ++it) {
qLinearGradient.setColorAt(it->first, QColor(it->second[0], it->second[1], it->second[2], it->second[3]));
}
painter.fillRect(rect, qLinearGradient);
}
else {
unsigned int nb = 0;
float rectWidth = ((float) rect.width()) / colorMap.size();
float rectHeight = ((float) rect.height()) / colorMap.size();
for (map<float, Color>::iterator it = colorMap.begin(); it != colorMap.end(); ++it) {
QRectF rectangle;
if (orientation == Qt::Horizontal) {
rectangle.setTopLeft(QPointF(rect.left() + nb * rectWidth, rect.top()));
rectangle.setSize(QSizeF(rectWidth, rect.height()));
}
else {
rectangle.setTopLeft(QPointF(rect.left(), rect.bottom() - (nb + 1) * rectHeight));
rectangle.setSize(QSizeF(rect.width(), rectHeight));
}
painter.fillRect(rectangle, QBrush(QColor(it->second[0], it->second[1], it->second[2], it->second[3])));
++nb;
}
}
}
示例9: boundingRect
//! \brief Return bounding rectangle arround a wireline
QRectF WireLine::boundingRect() const
{
QRectF rect;
rect.setTopLeft(p1());
rect.setBottomRight(p2());
rect = rect.normalized();
rect.adjust(-m_adjust, -m_adjust, +m_adjust, +m_adjust);
return rect;
}
示例10: lineBoundingRect
QRectF PdfDocument::lineBoundingRect(int line_number) const {
QRectF rect;
rect.setTopLeft(m_lines[line_number-1]);
rect.setWidth(pageDim().width());
rect.setHeight(50);
rect.translate(0, -25);
qDebug() << "Line rectangle" << rect;
return rect;
}
示例11: drawSquare
void GraphDraw::drawSquare(QPointF pt, double w)
{
painter.setRenderHint(QPainter::Antialiasing, false);
QRectF rect;
rect.setTopLeft(pt + QPointF(-w,-w));
rect.setBottomRight(pt + QPointF(w,w));
painter.drawRect(rect);
}
示例12:
QRectF UB1HEditableGraphicsSquareItem::rect() const
{
QRectF r;
r.setTopLeft(pos());
r.setWidth(wIsNeg ? -mSide : mSide);
r.setHeight(hIsNeg ? -mSide : mSide);
return r;
}
示例13: eventFilter
bool core::Connector::eventFilter(QObject *sender, QEvent *event)
{
// qDebug () << event->type();
if(event->type() == QEvent::MouseMove){
QMouseEvent *hEvent = (QMouseEvent*)event;
GraphicDetailedView *gdv = (GraphicDetailedView*)sender;
QPointF pos = mapFromScene(gdv->mapToScene(hEvent->pos()));
currentMousePos = pos;
// qDebug() << currentMousePos << "<< currentMousePos";
QRectF container = getContainerRect();
if(pos.x() < 0 && pos.y() < 0){
container.setTopLeft(pos);
container.setBottomRight(QPointF(0, 0));
}else if(pos.x() < 0 && pos.y() >= 0){
container.setBottomLeft(pos);
container.setTopRight(QPointF(0, 0));
}else if(pos.x() >= 0 && pos.y() < 0){
container.setTopRight(pos);
container.setBottomLeft(QPointF(0, 0));
}else if(pos.x() >= 0 && pos.y() >= 0){
container.setBottomRight(pos);
container.setTopLeft(QPointF(0, 0));
}else{
container= QRectF(0, 0, 0, 0);
}
setContainerRect(container);
if(isBuildingConector){
updateConectorLine(beginPoint, pos);
}
return true;
}
return GraphicObject::eventFilter(sender, event);
}
示例14: buildReferenceRect
static QRectF buildReferenceRect( const PolarCoordinatePlane* plane )
{
QRectF contentsRect;
QPointF referencePointAtTop = plane->translate( QPointF( 1, 0 ) );
QPointF temp = plane->translate( QPointF( 0, 0 ) ) - referencePointAtTop;
const double offset = temp.y();
referencePointAtTop.setX( referencePointAtTop.x() - offset );
contentsRect.setTopLeft( referencePointAtTop );
contentsRect.setBottomRight( referencePointAtTop + QPointF( 2*offset, 2*offset) );
return contentsRect;
}
示例15: onTimeout
void AutoFindPath::onTimeout()
{
qreal x1 = tempPointF_.x();
qreal y1 = tempPointF_.y();
qreal x2 = toPointF_.x();
qreal y2 = toPointF_.y();
qreal xNegative = (x2 - x1) > 0 ? 1.0 : -1.0;
qreal yNegative = (y2 - y1) > 0 ? 1.0 : -1.0;
xNegative = 1.0;
yNegative = 1.0;
qreal fromDistance = qSqrt(qPow(x2-x1, 2) + qPow(y2-y1, 2));
qreal xdif = xNegative * pace_ * (x2 - x1) / fromDistance;
qreal ydif = yNegative * pace_ * (y2 - y1) / fromDistance;
qreal x3 = x1 + xdif;
qreal y3 = y1 + ydif;
qreal toDistance = qSqrt(qPow(x3-x2, 2) + qPow(y3-y2, 2));
// qDebug() << tempPointF_ << toPointF_<< xNegative << yNegative<<fromDistance<<toDistance<< xdif << ydif;
tempPointF_.setX(x3);
tempPointF_.setY(y3);
if (toDistance <= radius_) {
// qDebug() << "STOP!";
timer_.stop();
if (rolePathMap_.contains(role_)) {
rolePathMap_.remove(role_);
}
this->deleteLater();
}
qreal ration = qAtan2(ydif, xdif);
qreal degree = qRadiansToDegrees(ration);
// qDebug() << ration << degree;
role_->setRotation(degree + 90);
// setRotation(rotation() + dx);
role_->setPos(tempPointF_);
// role_->setEyeDirection();
// role_->update();
// QRectF rect = role_->mapRectToScene(role_->boundingRect());
QPointF pos = role_->mapToScene(role_->pos());
QRectF rect;
rect.setTopLeft(pos);
rect.setWidth(20);
rect.setHeight(20);
role_->scene()->invalidate();
}