本文整理汇总了C++中QRectF::setLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setLeft方法的具体用法?C++ QRectF::setLeft怎么用?C++ QRectF::setLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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: adjustScrollBars
void AbstractScrollArea::adjustScrollBars()
{
if (m_horizontalScrollBarPolicy == Qt::ScrollBarAlwaysOff) {
m_horizontalScrollBar->hide();
} else {
m_horizontalScrollBar->show();
QRectF sbgeom = boundingRect();
sbgeom.setTop(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height());
sbgeom.setRight(sbgeom.right() - m_verticalScrollBar->boundingRect().width());
m_horizontalScrollBar->setGeometry(sbgeom);
}
if (m_verticalScrollBarPolicy == Qt::ScrollBarAlwaysOff) {
m_verticalScrollBar->hide();
QRectF sbgeom = boundingRect();
sbgeom.setLeft(sbgeom.right());
sbgeom.setBottom(sbgeom.bottom());
m_verticalScrollBar->setGeometry(sbgeom);
} else {
m_verticalScrollBar->show();
QRectF sbgeom = boundingRect();
sbgeom.setLeft(sbgeom.right() - m_verticalScrollBar->boundingRect().width());
if (m_horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff)
sbgeom.setBottom(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height());
m_verticalScrollBar->setGeometry(sbgeom);
}
}
示例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: 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();
}
示例8: 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();
}
示例9: run
void SearchDocumentJob::run()
{
Q_ASSERT(m_document);
for (int i = 0; i < m_document->numPages(); ++i) {
int ipage = (startPage + i) % m_document->numPages();
Poppler::Page *page = m_document->page(ipage);
double sLeft, sTop, sRight, sBottom;
float scaleW = 1.f / page->pageSizeF().width();
float scaleH = 1.f / page->pageSizeF().height();
bool found;
found = page->search(m_search, sLeft, sTop, sRight, sBottom,
Poppler::Page::FromTop,
Poppler::Page::IgnoreCase);
while (found) {
QRectF result;
result.setLeft(sLeft * scaleW);
result.setTop(sTop * scaleH);
result.setRight(sRight * scaleW);
result.setBottom(sBottom * scaleH);
m_matches.append(QPair<int, QRectF>(ipage, result));
found = page->search(m_search, sLeft, sTop, sRight, sBottom,
Poppler::Page::NextResult,
Poppler::Page::IgnoreCase);
}
delete page;
}
}
示例10: fm
TimelineBar::Marker *TimelineBar::findMarker(QVector<Marker> &markers, QRectF markerRect, QPointF pos)
{
QFontMetrics fm(Formatter::PreferredFont());
for(Marker &m : markers)
{
QRectF r = markerRect;
r.setLeft(qMax(m_markerRect.left() + borderWidth * 2, offsetOf(m.eidStart)));
r.setRight(qMin(m_markerRect.right() - borderWidth, offsetOf(m.eidEnd + 1)));
r.setHeight(fm.height() + borderWidth * 2);
if(r.width() <= borderWidth * 2)
continue;
if(r.contains(pos))
{
return &m;
}
if(!m.children.isEmpty() && m.expanded)
{
QRectF childRect = r;
childRect.setTop(r.bottom() + borderWidth * 2);
childRect.setBottom(markerRect.bottom());
Marker *res = findMarker(m.children, childRect, pos);
if(res)
return res;
}
}
return NULL;
}
示例11: documentArea
QRectF SheetPrint::documentArea(int page) const
{
if (d->m_lnewPageListX.isEmpty() || d->m_lnewPageListY.isEmpty()) {
return QRectF();
}
if (page - 1 > pageCount()) {
return QRectF();
}
int horizontalIndex = 0;
int verticalIndex = 0;
if (d->m_settings->pageOrder() == PrintSettings::LeftToRight) {
horizontalIndex = (page - 1) % d->m_lnewPageListX.count();
verticalIndex = (page - 1) / d->m_lnewPageListX.count();
} else {
horizontalIndex = (page - 1) / d->m_lnewPageListY.count();
verticalIndex = (page - 1) % d->m_lnewPageListY.count();
}
const PrintNewPageEntry horizontalParameters = d->m_lnewPageListX[horizontalIndex];
const PrintNewPageEntry verticalParameters = d->m_lnewPageListY[verticalIndex];
QRectF documentArea;
documentArea.setLeft(horizontalParameters.offset());
documentArea.setWidth(horizontalParameters.size());
documentArea.setTop(verticalParameters.offset());
documentArea.setHeight(verticalParameters.size());
return documentArea;
}
示例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: initPins
void ComponentItem::initPins()
{
QDomNode pinsNode;
QDomNodeList list = m_svgDocument.elementsByTagName("g");
for (int i=0;i<list.count();i++){
QDomNamedNodeMap attrs = list.item(i).attributes();
if (attrs.contains("id") &&
attrs.namedItem("id").toAttr().value() == QString("pins")){
pinsNode = list.item(i);
break;
}
}
if (pinsNode.isNull() || !pinsNode.hasChildNodes()){
kWarning() << "No pins definition found for this component";
return;
}
QDomElement pin = pinsNode.firstChildElement();
while (!pin.isNull()) {
QRectF pinRect;
double r = pin.attribute("r").toDouble();
pinRect.setLeft(pin.attribute("cx").toDouble());
pinRect.setTop(pin.attribute("cy").toDouble());
pinRect.setWidth(r*2);
pinRect.setHeight(r*2);
PinItem* p = new PinItem(pinRect, this, qobject_cast< IDocumentScene* >(scene()));
p->setId(pin.attribute("id"));
pin = pin.nextSiblingElement();
}
}
示例14: 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;
}
示例15: 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);
}
}