本文整理汇总了C++中QRectF::topRight方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::topRight方法的具体用法?C++ QRectF::topRight怎么用?C++ QRectF::topRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::topRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundingRect
QRectF RectangleShape::boundingRect() const
{
#define angle rotation()
QRectF tmp = self->boundingRect();
int centerX = (tmp.topLeft().x() + tmp.bottomRight().x()) / 2;
int centerY = (tmp.topLeft().y() + tmp.bottomRight().y()) / 2;
QPointF topLeft = QPoint(centerX + (tmp.topLeft().x() - centerX) * cos(angle)
- (tmp.topLeft().x() - centerY) * sin(angle),
centerY + (tmp.topLeft().y() - centerY) * cos(angle)
+ (tmp.topLeft().x() - centerX) * sin(angle));
QPointF topRight = QPoint(centerX + (tmp.topRight().x() - centerX) * cos(angle)
- (tmp.topRight().x() - centerY) * sin(angle),
centerY + (tmp.topRight().y() - centerY) * cos(angle)
+ (tmp.topRight().x() - centerX) * sin(angle));
QPointF bottomRight = QPoint(centerX + (tmp.bottomRight().x() - centerX) * cos(angle)
- (tmp.bottomRight().x() - centerY) * sin(angle),
centerY + (tmp.bottomRight().y() - centerY) * cos(angle)
+ (tmp.bottomRight().x() - centerX) * sin(angle));
QPointF bottomLeft = QPoint(centerX + (tmp.bottomLeft().x() - centerX) * cos(angle)
- (tmp.bottomLeft().x() - centerY) * sin(angle),
centerY + (tmp.bottomLeft().y() - centerY) * cos(angle)
+ (tmp.bottomLeft().x() - centerX) * sin(angle));
QPointF newTopLeft = QPointF(topLeft.x(), topRight.y());
QPointF newBottomRight = QPointF(bottomRight.x(), bottomLeft.y());
tmp = QRectF(newTopLeft, newBottomRight);
return tmp;
}
示例2: drawScaleOverlay
void Collider::drawScaleOverlay(QPainter *painter, QPen pen, QRectF outlineRect)
{
painter->setBrush (Qt::NoBrush);
painter->setOpacity (0.9);
pen.setStyle (Qt::SolidLine);
// draw rect bounds
painter->drawRect (outlineRect);
painter->setBrush (Qt::NoBrush);
int cSize = mScaleFeedbackRectsSize;
//Corners
QVector<QRectF> rects;
// The first four is the corners and the next four is the middle of the sides.
rects << QRectF( outlineRect.topLeft ().x()-(cSize/2), outlineRect.topLeft ().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomLeft ().x()-(cSize/2), outlineRect.bottomLeft ().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.topRight ().x()-(cSize/2), outlineRect.topRight ().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomRight ().x()-(cSize/2), outlineRect.bottomRight ().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomRight ().x()-(outlineRect.width()/2)-(cSize/2), outlineRect.bottomRight ().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomRight ().x()-(outlineRect.width()/2)-(cSize/2), outlineRect.topRight().y()-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomLeft ().x()-(cSize/2), outlineRect.bottomRight ().y()-(outlineRect.height()/2)-(cSize/2),cSize,cSize)
<< QRectF( outlineRect.bottomRight().x()-(cSize/2), outlineRect.bottomRight ().y()-(outlineRect.height()/2)-(cSize/2),cSize,cSize);
painter->setBrush (QColor(Qt::blue));
pen.setStyle (Qt::SolidLine);
painter->drawRects (rects);
}
示例3: paint
void Target::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{
Q_UNUSED(w);
Q_UNUSED(option);
QColor color;
color = QColor("green");
color.setAlpha(180);
QRectF square = boundingRect();
painter->setBrush(color);
painter->drawRoundRect(square);
painter->save();
color = QColor("white");
color.setAlpha(220);
painter->setPen(color);
QPointF point1 = QPointF(square.topLeft().x() + 3, square.topLeft().y() + 3);
QPointF point2 = QPointF(square.bottomRight().x() - 3, square.bottomRight().y() - 3);
QPointF point3 = QPointF(square.bottomLeft().x() + 3, square.bottomLeft().y() - 3);
QPointF point4 = QPointF(square.topRight().x() - 3, square.topRight().y() + 3);
painter->drawLine(point1, point2);
painter->drawLine(point3, point4);
painter->restore();
}
示例4: rectSection
Qt::WindowFrameSection OverlayEditorScene::rectSection(const QRectF &qrf, const QPointF &qp, qreal dist) {
qreal left, right, top, bottom;
top = distancePointLine(qrf.topLeft(), qrf.topRight(), qp);
bottom = distancePointLine(qrf.bottomLeft(), qrf.bottomRight(), qp);
left = distancePointLine(qrf.topLeft(), qrf.bottomLeft(), qp);
right = distancePointLine(qrf.topRight(), qrf.bottomRight(), qp);
if ((top < dist) && (top < bottom)) {
if ((left < dist) && (left < right))
return Qt::TopLeftSection;
else if (right < dist)
return Qt::TopRightSection;
return Qt::TopSection;
} else if (bottom < dist) {
if ((left < dist) && (left < right))
return Qt::BottomLeftSection;
else if (right < dist)
return Qt::BottomRightSection;
return Qt::BottomSection;
} else if (left < dist) {
return Qt::LeftSection;
} else if (right < dist) {
return Qt::RightSection;
}
if (qrf.contains(qp))
return Qt::TitleBarArea;
return Qt::NoSection;
}
示例5: paintFrontView
void FacebookContactUI::paintFrontView(QPainter *painter, const QRectF &rect)
{
QPainterPath backgroundPath;
backgroundPath.addRoundedRect(rect, 6.0, 6.0);
painter->fillPath(backgroundPath, QColor(235, 235, 235));
if (d->mSearchBox) {
QRectF searchBoxRect = QRectF (0.0, d->mScrollView->contentRect().height() + 28,
rect.width(), rect.height());
QRectF searchBoxLineRect = QRectF (0.0, d->mScrollView->contentRect().height() + 29,
rect.width(), rect.height());
QPen pen = QPen(QColor(220, 220, 220), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
QLinearGradient linearGrad(searchBoxRect.topRight(), searchBoxRect.bottomRight());
linearGrad.setColorAt(0, QColor(93, 103, 114));
linearGrad.setColorAt(1, QColor(66, 77, 88));
painter->fillRect(searchBoxRect, linearGrad);
painter->drawLine(searchBoxRect.topRight(), searchBoxRect.topLeft());
pen = QPen(QColor(88, 88, 88), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
painter->drawLine(searchBoxLineRect.topRight(), searchBoxLineRect.topLeft());
}
}
示例6: adjustX
QPainterPath
TriggerPoint::shape() const
{
QPainterPath path;
float line = BasicBox::LINE_WIDTH / 2;
QPointF adjustX(-line, 0);
QPointF adjustY(0, -line);
QRectF rect = boundingRect();
switch (_abstract->boxExtremity()) {
case BOX_START:
path.moveTo(rect.topLeft() + adjustX);
path.lineTo(rect.bottomLeft() + adjustX + adjustY);
path.lineTo(rect.bottomRight() + adjustY);
path.lineTo(rect.bottomRight() + adjustY - QPointF(0, rect.height() / 5.));
path.quadTo(rect.topRight(), rect.topLeft() + adjustX);
break;
case BOX_END:
path.moveTo(rect.topRight());
path.lineTo(rect.bottomRight() + adjustY);
path.lineTo(rect.bottomLeft() + adjustY);
path.lineTo(rect.bottomLeft() + adjustY - QPointF(0, rect.height() / 5.));
path.quadTo(rect.topLeft(), rect.topRight());
break;
default:
break;
}
return path;
}
示例7: determinePointsInSelection
void ItemScene::determinePointsInSelection()
{
QRectF controlRect = this->selectionPathItem->path().controlPointRect();
QPainterPath path = this->selectionPathItem->path();
QImage sourceImage = this->imageFileItem->pixmap().toImage();
QImage extractedImage(controlRect.width(), controlRect.height(), QImage::Format_RGB888);
for(int yPos = controlRect.topLeft().y(); yPos < controlRect.topLeft().y() + controlRect.height(); yPos++)
{
for(int xPos = controlRect.topLeft().x(); xPos < controlRect.topLeft().x() + controlRect.width(); xPos++)
{
if(path.contains(QPointF(xPos, yPos)))
{
extractedImage.setPixel( xPos - (controlRect.topRight().x() - controlRect.width()), yPos - (controlRect.bottomLeft().y() - controlRect.height()),sourceImage.pixel(xPos, yPos));
}
else extractedImage.setPixel( xPos - (controlRect.topRight().x() - controlRect.width()), yPos - (controlRect.bottomLeft().y() - controlRect.height()), QRgb(qRgb(255,255,255)));
}
}
this->imageFileItem->setPixmap(QPixmap::fromImage(extractedImage));
this->imageFileItem->setPos(this->sceneRect().center().operator -=(QPointF(extractedImage.width()/2, extractedImage.height()/2)));
this->imageFileItem->update();
this->removeItem(this->selectionPathItem);
for(QList<SelectionMarker*>::iterator iterator = this->selectionMarkers->begin(); iterator != this->selectionMarkers->end(); iterator++)
{
this->removeItem( (*iterator));
}
}
示例8: updateAnchorLinePoints
static void updateAnchorLinePoints(QPointF *firstPoint, QPointF *secondPoint, const AnchorLine &anchorLine)
{
QRectF boundingRectangle = anchorLine.qmlItemNode().instanceBoundingRect().adjusted(0., 0., 1., 1.);
switch (anchorLine.type()) {
case AnchorLine::Top:
*firstPoint = boundingRectangle.topLeft();
*secondPoint = boundingRectangle.topRight();
break;
case AnchorLine::Bottom:
*firstPoint = boundingRectangle.bottomLeft();
*secondPoint = boundingRectangle.bottomRight();
break;
case AnchorLine::Left:
*firstPoint = boundingRectangle.topLeft();
*secondPoint = boundingRectangle.bottomLeft();
break;
case AnchorLine::Right:
*firstPoint = boundingRectangle.topRight();
*secondPoint = boundingRectangle.bottomRight();
break;
default:
break;
}
*firstPoint = anchorLine.qmlItemNode().instanceSceneTransform().map(*firstPoint);
*secondPoint = anchorLine.qmlItemNode().instanceSceneTransform().map(*secondPoint);
}
示例9: updateGeometry
static void updateGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &textureRect)
{
auto *v = LightedPoint2D::from(g);
v[0] = { QVector2D(rect.topLeft()), QVector2D(textureRect.topLeft()), QVector2D(), QVector2D() };
v[1] = { QVector2D(rect.bottomLeft()), QVector2D(textureRect.bottomLeft()), QVector2D(), QVector2D() };
v[2] = { QVector2D(rect.topRight()), QVector2D(textureRect.topRight()), QVector2D(), QVector2D() };
v[3] = { QVector2D(rect.bottomRight()), QVector2D(textureRect.bottomRight()), QVector2D(), QVector2D() };
}
示例10: QRectInterstects
bool Utils::QRectInterstects(const QRectF& r, const QLineF& lF, QPointF& a, QPointF& b)
{
QPointF pF;
bool hasP1 = false;
bool hasP2 = false;
if (QLineF(r.topLeft(), r.bottomLeft()).intersect(lF, &pF) == QLineF::BoundedIntersection) {
a = pF;
hasP1 = true;
}
if (QLineF(r.bottomLeft(), r.bottomRight()).intersect(lF, &pF) == QLineF::BoundedIntersection) {
if (hasP1) {
b = pF;
hasP2 = true;
} else {
a = pF;
hasP1 = true;
}
}
if (QLineF(r.bottomRight(), r.topRight()).intersect(lF, &pF) == QLineF::BoundedIntersection) {
if (hasP1) {
b = pF;
hasP2 = true;
} else {
a = pF;
hasP1 = true;
}
}
if (QLineF(r.topRight(), r.topLeft()).intersect(lF, &pF) == QLineF::BoundedIntersection) {
if (hasP1) {
b = pF;
hasP2 = true;
} else {
a = pF;
hasP1 = true;
}
}
if (hasP1 && hasP2) {
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
qreal la1 = QLineF(a,b).angleTo(lF);
#else
qreal la1 = QLineF(a,b).angle(lF);
#endif
if (la1 > 15.0 && la1 < 345.0) {
QPointF t = b;
b = a;
a = t;
}
}
if (hasP1)
return true;
else
return false;
}
示例11: drawLines
/*!
Draw a histogram in Lines style()
\param painter Painter
\param xMap Maps x-values into pixel coordinates.
\param yMap Maps y-values into pixel coordinates.
\param from Index of the first sample to be painted
\param to Index of the last sample to be painted. If to < 0 the
histogram will be painted to its last point.
\sa setStyle(), style(), setPen()
*/
void QwtPlotHistogram::drawLines( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to ) const
{
const bool doAlign = QwtPainter::roundingAlignment( painter );
painter->setPen( d_data->pen );
painter->setBrush( Qt::NoBrush );
for ( int i = from; i <= to; i++ )
{
const QwtIntervalSample sample = d_series->sample( i );
if ( !sample.interval.isNull() )
{
const QwtColumnRect rect = columnRect( sample, xMap, yMap );
QRectF r = rect.toRect();
if ( doAlign )
{
r.setLeft( qRound( r.left() ) );
r.setRight( qRound( r.right() ) );
r.setTop( qRound( r.top() ) );
r.setBottom( qRound( r.bottom() ) );
}
switch ( rect.direction )
{
case QwtColumnRect::LeftToRight:
{
QwtPainter::drawLine( painter,
r.topRight(), r.bottomRight() );
break;
}
case QwtColumnRect::RightToLeft:
{
QwtPainter::drawLine( painter,
r.topLeft(), r.bottomLeft() );
break;
}
case QwtColumnRect::TopToBottom:
{
QwtPainter::drawLine( painter,
r.bottomRight(), r.bottomLeft() );
break;
}
case QwtColumnRect::BottomToTop:
{
QwtPainter::drawLine( painter,
r.topRight(), r.topLeft() );
break;
}
}
}
}
}
示例12: paint
void CanvasRect::paint(QPainter *painter, const QTransform &tran, const QRectF &limits)
{
QRectF plotRect = bounds();
// Let's not waste time here...
if (!limits.intersects(plotRect)) return;
// TODO: This boilerplate style stuff to a CanvasShape::applyStyle(QPainter*) func?
QPen pen;
LineSpec *ln = lineSpec();
pen.setColor(ln->color());
pen.setWidthF(ln->width());
QString style = ln->style();
if (style == ".") {
pen.setStyle(Qt::SolidLine);
} else {
pen.setStyle( LineSpec::styleMap[style] );
}
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(fillSpec()->color());
painter->setRenderHint(QPainter::Antialiasing);
// Only draw the part of the rect in the view
QRectF rect = limits.intersected(plotRect);
// Figure out which sides still need lines...
QVector<QLineF> lines;
if (rect.left() == plotRect.left())
lines << QLineF(rect.bottomLeft(), rect.topLeft());
if (rect.right() == plotRect.right())
lines << QLineF(rect.bottomRight(), rect.topRight());
if (rect.top() == plotRect.top())
lines << QLineF(rect.topLeft(), rect.topRight());
if (rect.bottom() == plotRect.bottom())
lines << QLineF(rect.bottomLeft(), rect.bottomRight());
// Map the fill and lines
QRectF mappedRect = tran.mapRect(rect);
for (int i=0; i<lines.length(); ++i) {
lines[i] = tran.map(lines[i]);
}
// Draw the rect
painter->setPen(Qt::NoPen);
painter->setBrush(brush);
painter->drawRect(mappedRect);
// Draw the outline
painter->setBrush(Qt::NoBrush);
painter->setPen(pen);
painter->drawLines(lines);
}
示例13: setRect
void TexturedGeometry::setRect(const QRectF &r, const QRectF &tr)
{
setPoint(0, r.topLeft(), tr.topLeft());
setPoint(1, r.bottomLeft(), tr.bottomLeft());
if (tri == Strip) {
setPoint(2, r.topRight(), tr.topRight());
setPoint(3, r.bottomRight(), tr.bottomRight());
} else {
setPoint(3, r.topRight(), tr.topRight());
setPoint(2, r.bottomRight(), tr.bottomRight());
}
}
示例14: setViewportArea
void SlippyMapWidget::setViewportArea(QRectF theRect)
{
qreal zoom = 360.0 / theRect.width();
zoom = log10(zoom)/log10(2.0);
if (zoom < MINZOOMLEVEL)
zoom = MINZOOMLEVEL;
if (zoom > MAXZOOMLEVEL)
zoom = MAXZOOMLEVEL;
p->VpZoom = int(zoom);
p->VpLon = long2tile(theRect.topRight().x(), p->VpZoom);
p->VpLat = lat2tile(theRect.topRight().y(), p->VpZoom);
}
示例15: qwtDrawPanel
static void qwtDrawPanel( QPainter *painter, const QRectF &rect,
const QPalette &pal, double lw )
{
if ( lw > 0.0 )
{
if ( rect.width() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.bottomLeft() );
return;
}
if ( rect.height() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.topRight() );
return;
}
lw = qMin( lw, rect.height() / 2.0 - 1.0 );
lw = qMin( lw, rect.width() / 2.0 - 1.0 );
const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 );
const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw );
QPolygonF lines[2];
lines[0] += outerRect.bottomLeft();
lines[0] += outerRect.topLeft();
lines[0] += outerRect.topRight();
lines[0] += innerRect.topRight();
lines[0] += innerRect.topLeft();
lines[0] += innerRect.bottomLeft();
lines[1] += outerRect.topRight();
lines[1] += outerRect.bottomRight();
lines[1] += outerRect.bottomLeft();
lines[1] += innerRect.bottomLeft();
lines[1] += innerRect.bottomRight();
lines[1] += innerRect.topRight();
painter->setPen( Qt::NoPen );
painter->setBrush( pal.light() );
painter->drawPolygon( lines[0] );
painter->setBrush( pal.dark() );
painter->drawPolygon( lines[1] );
}
painter->fillRect( rect.adjusted( lw, lw, -lw + 1, -lw + 1 ), pal.window() );
}