本文整理汇总了C++中QRectF::setTop方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setTop方法的具体用法?C++ QRectF::setTop怎么用?C++ QRectF::setTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setTop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blitTexture
static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
{
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glViewport(0, 0, viewport.width(), viewport.height());
QGLShaderProgram *blitProgram =
QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
blitProgram->bind();
blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
// The shader manager's blit program does not multiply the
// vertices by the pmv matrix, so we need to do the effect
// of the orthographic projection here ourselves.
QRectF r;
qreal w = viewport.width();
qreal h = viewport.height();
r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
if (targetRect.right() == (viewport.width() - 1))
r.setRight(1.0f);
else
r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
if (targetRect.bottom() == (viewport.height() - 1))
r.setTop(1.0f);
else
r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
drawTexture(r, texture, texSize, sourceRect);
}
示例2: updateAnimation
void UIGraphicsZoomButton::updateAnimation()
{
QRectF oldRect = geometry();
QRectF newRect = oldRect;
if (m_iDirection & UIGraphicsZoomDirection_Top)
newRect.setTop(newRect.top() - m_iIndent);
if (m_iDirection & UIGraphicsZoomDirection_Bottom)
newRect.setBottom(newRect.bottom() + m_iIndent);
if (m_iDirection & UIGraphicsZoomDirection_Left)
newRect.setLeft(newRect.left() - m_iIndent);
if (m_iDirection & UIGraphicsZoomDirection_Right)
newRect.setRight(newRect.right() + m_iIndent);
if (!(m_iDirection & UIGraphicsZoomDirection_Left) &&
!(m_iDirection & UIGraphicsZoomDirection_Right))
{
newRect.setLeft(newRect.left() - m_iIndent / 2);
newRect.setRight(newRect.right() + m_iIndent / 2);
}
if (!(m_iDirection & UIGraphicsZoomDirection_Top) &&
!(m_iDirection & UIGraphicsZoomDirection_Bottom))
{
newRect.setTop(newRect.top() - m_iIndent / 2);
newRect.setBottom(newRect.bottom() + m_iIndent / 2);
}
m_pForwardAnimation->setStartValue(oldRect);
m_pForwardAnimation->setEndValue(newRect);
m_pBackwardAnimation->setStartValue(newRect);
m_pBackwardAnimation->setEndValue(oldRect);
}
示例3: addBBox
QRectF addBBox(QRectF r1, QRectF r2)
{
// Find smallest QRectF containing given rectangles
QRectF n;
// Set left border
if (r1.left() <= r2.left() )
n.setLeft(r1.left() );
else
n.setLeft(r2.left() );
// Set top border
if (r1.top() <= r2.top() )
n.setTop(r1.top() );
else
n.setTop(r2.top() );
// Set right border
if (r1.right() <= r2.right() )
n.setRight(r2.right() );
else
n.setRight(r1.right() );
// Set bottom
if (r1.bottom() <= r2.bottom() )
n.setBottom(r2.bottom() );
else
n.setBottom(r1.bottom() );
return n;
}
示例4: boundingRect
/*!
\return Bounding rectangle of the data
\sa QwtPlotRasterItem::interval()
*/
QRectF QwtPlotRasterItem::boundingRect() const
{
const QwtInterval intervalX = interval( Qt::XAxis );
const QwtInterval intervalY = interval( Qt::YAxis );
if ( !intervalX.isValid() && !intervalY.isValid() )
return QRectF(); // no bounding rect
QRectF r;
if ( intervalX.isValid() )
{
r.setLeft( intervalX.minValue() );
r.setRight( intervalX.maxValue() );
}
else
{
r.setLeft(-0.5 * FLT_MAX);
r.setWidth(FLT_MAX);
}
if ( intervalY.isValid() )
{
r.setTop( intervalY.minValue() );
r.setBottom( intervalY.maxValue() );
}
else
{
r.setTop(-0.5 * FLT_MAX);
r.setHeight(FLT_MAX);
}
return r.normalized();
}
示例5: setOpacityTransferFunction
void QOpacityTransferFunctionGraphicalView::setOpacityTransferFunction(const OpacityTransferFunction &opacityTransferFunction)
{
scene()->clear();
QList<double> keys = opacityTransferFunction.keys();
QRectF rect;
bool first = true;
QOpacityTransferFunctionGraphicalViewNode *previousNode = 0;
foreach (double x, keys)
{
double opacity = opacityTransferFunction.get(x);
QOpacityTransferFunctionGraphicalViewNode *node = new QOpacityTransferFunctionGraphicalViewNode();
node->setX(x);
node->setY(opacity);
node->setToolTip(QString("(%1, %2)").arg(x).arg(opacity));
scene()->addItem(node);
if (previousNode)
{
QOpacityTransferFunctionGraphicalViewLine *line = new QOpacityTransferFunctionGraphicalViewLine();
line->setLeftNode(previousNode);
line->setRightNode(node);
previousNode->setRightLine(line);
node->setLeftLine(line);
scene()->addItem(line);
}
if (first)
{
first = false;
rect.setLeft(x);
rect.setRight(x);
rect.setTop(opacity);
rect.setBottom(opacity);
}
else
{
if (x < rect.left())
{
rect.setLeft(x);
}
if (x > rect.right())
{
rect.setRight(x);
}
if (opacity < rect.top())
{
rect.setTop(opacity);
}
if (opacity > rect.bottom())
{
rect.setBottom(opacity);
}
}
previousNode = node;
}
示例6: colorBarRect
/*!
Calculate the the rectangle for the color bar
\param rect Bounding rectangle for all components of the scale
\return Rectangle for the color bar
*/
QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const
{
QRectF cr = rect;
if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
{
cr.setLeft( cr.left() + d_data->borderDist[0] );
cr.setWidth( cr.width() - d_data->borderDist[1] + 1 );
}
else
{
cr.setTop( cr.top() + d_data->borderDist[0] );
cr.setHeight( cr.height() - d_data->borderDist[1] + 1 );
}
switch ( d_data->scaleDraw->alignment() )
{
case QwtScaleDraw::LeftScale:
{
cr.setLeft( cr.right() - d_data->margin
- d_data->colorBar.width );
cr.setWidth( d_data->colorBar.width );
break;
}
case QwtScaleDraw::RightScale:
{
cr.setLeft( cr.left() + d_data->margin );
cr.setWidth( d_data->colorBar.width );
break;
}
case QwtScaleDraw::BottomScale:
{
cr.setTop( cr.top() + d_data->margin );
cr.setHeight( d_data->colorBar.width );
break;
}
case QwtScaleDraw::TopScale:
{
cr.setTop( cr.bottom() - d_data->margin
- d_data->colorBar.width );
cr.setHeight( d_data->colorBar.width );
break;
}
}
return cr;
}
示例7: drawForeground
void QGraphVizPIP::drawForeground(QPainter *painter, const QRectF &rect)
{
if(!rect.intersects(m_ViewPortRect)) {
return;
}
if(m_ViewPortRect.contains(scene()->sceneRect())) {
return;
}
QColor color(Qt::red);
QPen pen;
pen.setColor(color);
painter->setPen(pen);
QBrush brush;
color.setAlphaF(.1);
brush.setColor(color);
brush.setStyle(Qt::SolidPattern);
painter->setBrush(brush);
QRectF sceneRect = this->sceneRect().adjusted(-10,-10,20,20);
QRectF viewPortRect;
viewPortRect.setLeft(qMax(sceneRect.left(), m_ViewPortRect.left()));
viewPortRect.setTop(qMax(sceneRect.top(), m_ViewPortRect.top()));
viewPortRect.setRight(qMin(sceneRect.right(), m_ViewPortRect.right()));
viewPortRect.setBottom(qMin(sceneRect.bottom(), m_ViewPortRect.bottom()));
painter->drawRect(viewPortRect);
}
示例8: getRect
QRectF ODrawClient::getRect(const MSO::OfficeArtClientAnchor& clientAnchor)
{
const MSO::XlsOfficeArtClientAnchor* anchor = clientAnchor.anon.get<MSO::XlsOfficeArtClientAnchor>();
if (anchor) {
QRectF r;
qreal colWidth = columnWidth(m_sheet, anchor->colL);
r.setLeft(offset(colWidth, anchor->dxL, 1024));
if (anchor->colR == anchor->colL) {
r.setRight(offset(colWidth, anchor->dxR, 1024));
} else {
qreal width = colWidth - r.left();
for (int col = anchor->colL + 1; col < anchor->colR; ++col) {
width += columnWidth(m_sheet, col);
}
width += offset(columnWidth(m_sheet, anchor->colR), anchor->dxR, 1024);
r.setWidth(width);
}
qreal rowHgt = rowHeight(m_sheet, anchor->rwT);
r.setTop(offset(rowHgt, anchor->dyT, 256));
if (anchor->rwT == anchor->rwB) {
r.setBottom(offset(rowHgt, anchor->dyB, 256));
} else {
qreal height = rowHgt - r.top();
for (int row = anchor->rwT + 1; row < anchor->rwB; ++row) {
height += rowHeight(m_sheet, row);
}
height += offset(rowHeight(m_sheet, anchor->rwB), anchor->dyB, 256);
r.setHeight(height);
}
return r;
} else {
qDebug() << "Invalid client anchor!";
}
return QRectF();
}
示例9: updateMap
void MiniMap::updateMap()
{
QRectF maxRect;
maxRect.setLeft( sceneRect().x() < visibleRect.x() ? sceneRect().x() : visibleRect.x() );
maxRect.setTop( sceneRect().y() < visibleRect.y() ? sceneRect().y() : visibleRect.y() );
maxRect.setRight( (sceneRect().x() + sceneRect().width()) > (visibleRect.x()+visibleRect.width())
? (sceneRect().x() + sceneRect().width()) : (visibleRect.x()+visibleRect.width()));
maxRect.setBottom( (sceneRect().y() + sceneRect().height()) > (visibleRect.y()+visibleRect.height())
? (sceneRect().y() + sceneRect().height()) : (visibleRect.y()+visibleRect.height()));
qreal xScale = (width() - 2*frameWidth() - 2*margin) / maxRect.width();
qreal yScale = (height() - 2*frameWidth() - 2*margin) / maxRect.height();
qreal scale = xScale < yScale ? xScale : yScale;
qreal rectX = margin + (visibleRect.x() - maxRect.x())*scale;
qreal rectY = margin + (visibleRect.y() - maxRect.y())*scale;
if (xScale < yScale) rectY += (height() - 2*(frameWidth() + margin) - maxRect.height()*scale) / 2;
else rectX += (width() - 2*(frameWidth() + margin) - maxRect.width()*scale) / 2;
// Below we subtract 0.5 and take the ceiling. This rounds the number. We further subtract 1 in order to compensate
// for the pen width of the drawn rectangle.
drawnRect.setRect(rectX, rectY, ceil(visibleRect.width()*scale - 1.5), ceil(visibleRect.height()*scale - 1.5));
setTransform(QTransform::fromScale(scale,scale).translate(margin, margin));
viewport()->update();
}
示例10: setBoundries
void StaffScene::setBoundries()
{
QRectF rec = sceneRect();
rec.setTop(rec.top() - noteProperties::noteDiameter);
rec.setBottom(rec.bottom() + noteProperties::noteDiameter);
setSceneRect(rec);
}
示例11: mergeCoordinates
void CallbackBoundingRects::mergeCoordinates (const QPointF &pos,
QRectF &boundingRect)
{
bool newGraphLeft = m_isEmpty;
bool newGraphTop = m_isEmpty;
bool newGraphRight = m_isEmpty;
bool newGraphBottom = m_isEmpty;
if (!newGraphLeft) {
newGraphLeft = (pos.x() < boundingRect.left());
}
if (!newGraphTop) {
newGraphTop = (pos.y() < boundingRect.top());
}
if (!newGraphRight) {
newGraphRight = (boundingRect.right() < pos.x());
}
if (!newGraphBottom) {
newGraphBottom = (boundingRect.bottom() < pos.y());
}
if (newGraphLeft) {
boundingRect.setLeft (pos.x());
}
if (newGraphTop) {
boundingRect.setTop (pos.y());
}
if (newGraphRight) {
boundingRect.setRight (pos.x());
}
if (newGraphBottom) {
boundingRect.setBottom (pos.y());
}
}
示例12: updateDataLimits
void LineSegmentPlot::updateDataLimits()
{
qDebug() << Q_FUNC_INFO;
int xLen = xSize(), yLen = ySize(), endXLen = m_endX.size(), endYLen = m_endY.size();
int N = qMin( qMin(xLen, yLen), qMin(endXLen, endYLen) );
m_dataSize = N;
qreal minX = Inf, maxX = -Inf, minY = Inf, maxY = -Inf;
// Calculate the y limits
RangeValues yrng = ArrayUtil::limits(yData());
minY = yrng.min;
maxY = yrng.max;
yrng = ArrayUtil::limits(m_endY);
minY = qMin(minY, yrng.min);
maxY = qMax(maxY, yrng.max);
RangeValues xrng = ArrayUtil::limits(xData());
minX = xrng.min;
maxX = xrng.max;
xrng = ArrayUtil::limits(m_endX);
minX = qMin(minX, xrng.min);
maxX = qMax(maxX, xrng.max);
QRectF newLim;
newLim.setLeft(minX);
newLim.setTop(minY);
newLim.setRight(maxX);
newLim.setBottom(maxY);
setDataLimits(newLim);
}
示例13: closestAcceptableGeometry
QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
{
Q_Q(const QWidgetWindow);
const QWidget *widget = q->widget();
if (!widget->isWindow() || !widget->hasHeightForWidth())
return QRect();
const QSize oldSize = rect.size().toSize();
const QSize newSize = QLayout::closestAcceptableSize(widget, oldSize);
if (newSize == oldSize)
return QRectF();
const int dw = newSize.width() - oldSize.width();
const int dh = newSize.height() - oldSize.height();
QRectF result = rect;
const QRectF currentGeometry(widget->geometry());
const qreal topOffset = result.top() - currentGeometry.top();
const qreal bottomOffset = result.bottom() - currentGeometry.bottom();
if (qAbs(topOffset) > qAbs(bottomOffset))
result.setTop(result.top() - dh); // top edge drag
else
result.setBottom(result.bottom() + dh); // bottom edge drag
const qreal leftOffset = result.left() - currentGeometry.left();
const qreal rightOffset = result.right() - currentGeometry.right();
if (qAbs(leftOffset) > qAbs(rightOffset))
result.setLeft(result.left() - dw); // left edge drag
else
result.setRight(result.right() + dw); // right edge drag
return result;
}
示例14: onViewChanged
void HeightMapEditor::onViewChanged(const QRectF & rect)
{
if (!myGraph) return;
if (myUi->renderView->scene()->children().count() > 50)
{
QList<QGraphicsItem *> items = myUi->renderView->scene()->items();
for (QGraphicsItem * i : items)
if (!i->isVisible())
myUi->renderView->scene()->removeItem(i);
}
QRectF trect;
trect.setLeft(rect.left() - fmod(rect.left(), myCellSize.width()));
trect.setTop(rect.top() - fmod(rect.top(), myCellSize.height()));
trect.setRight(rect.right() - fmod(rect.right(), myCellSize.width()));
trect.setBottom(rect.bottom() - fmod(rect.bottom(), myCellSize.height()));
for (double y = trect.top() - fmod(trect.top(), myCellSize.height());
y < trect.bottom() + myCellSize.height() - fmod(trect.bottom(), myCellSize.height());
y += myCellSize.height())
for (double x = trect.left() - fmod(trect.left(), myCellSize.width());
x < trect.right() + myCellSize.width() - fmod(trect.right(), myCellSize.width());
x += myCellSize.width())
{
QRectF r(x,y,myCellSize.width(), myCellSize.height());
generateRect(r);
}
}
示例15: boundingRect
/*!
\return Bounding rectangle of all samples.
For an empty series the rectangle is invalid.
*/
QRectF QwtPlotHistogram::boundingRect() const
{
QRectF rect = d_series->boundingRect();
if ( !rect.isValid() )
return rect;
if ( orientation() == Qt::Horizontal )
{
rect = QRectF( rect.y(), rect.x(),
rect.height(), rect.width() );
if ( rect.left() > d_data->baseline )
rect.setLeft( d_data->baseline );
else if ( rect.right() < d_data->baseline )
rect.setRight( d_data->baseline );
}
else
{
if ( rect.bottom() < d_data->baseline )
rect.setBottom( d_data->baseline );
else if ( rect.top() > d_data->baseline )
rect.setTop( d_data->baseline );
}
return rect;
}