本文整理汇总了C++中QRectF::setRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setRect方法的具体用法?C++ QRectF::setRect怎么用?C++ QRectF::setRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundingRect
// Forme englobante
QRectF Mur::boundingRect() const
{
QRectF boite;
switch(mur_)
{
case 0 :
boite.setRect(scene()->width() - 50, 50, 1, scene()->height() - 100);
break;
case 1 :
boite.setRect(50, scene()->height() - 50, scene()->width() - 100, 1);
break;
case 2 :
boite.setRect(50, 50, 1, scene()->height() - 100);
break;
case 3 :
boite.setRect(50, 50, scene()->width() - 100, 1);
break;
}
return boite;
}
示例2: scaleView
void ZoomTool::scaleView(const QPointF ¢erPos)
{
QTransform transform;
transform.scale(m_currentScale, m_currentScale);
view()->setTransform(transform);
QPointF adjustedCenterPos = centerPos;
QSize rectSize(view()->rect().width() / m_currentScale,
view()->rect().height() / m_currentScale);
QRectF sceneRect;
if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) {
adjustedCenterPos.rx() = rectSize.width() / 2;
adjustedCenterPos.ry() = rectSize.height() / 2;
}
if (m_currentScale < 1.0f) {
adjustedCenterPos.rx() = rectSize.width() / 2;
adjustedCenterPos.ry() = rectSize.height() / 2;
sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
view()->rect().height() / 2 -rectSize.height() / 2,
rectSize.width(),
rectSize.height());
} else {
sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
adjustedCenterPos.y() - rectSize.height() / 2,
rectSize.width(),
rectSize.height());
}
view()->setSceneRect(sceneRect);
}
示例3: boundingRect
/*!
\return Bounding rectangle of all samples.
For an empty series the rectangle is invalid.
*/
QRectF QwtPlotMultiBarChart::boundingRect() const
{
const size_t numSamples = dataSize();
if ( numSamples == 0 )
return QwtPlotSeriesItem::boundingRect();
const double baseLine = baseline();
QRectF rect;
if ( d_data->style != QwtPlotMultiBarChart::Stacked )
{
rect = QwtPlotSeriesItem::boundingRect();
if ( rect.height() >= 0 )
{
if ( rect.bottom() < baseLine )
rect.setBottom( baseLine );
if ( rect.top() > baseLine )
rect.setTop( baseLine );
}
}
else
{
double xMin, xMax, yMin, yMax;
xMin = xMax = 0.0;
yMin = yMax = baseLine;
const QwtSeriesData<QwtSetSample> *series = data();
for ( size_t i = 0; i < numSamples; i++ )
{
const QwtSetSample sample = series->sample( i );
if ( i == 0 )
{
xMin = xMax = sample.value;
}
else
{
xMin = qMin( xMin, sample.value );
xMax = qMax( xMax, sample.value );
}
const double y = baseLine + sample.added();
yMin = qMin( yMin, y );
yMax = qMax( yMax, y );
}
rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin );
}
if ( orientation() == Qt::Horizontal )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect;
}
示例4: paintEvent
void SSlider::paintEvent(QPaintEvent*) {
// This whole function is suboptimal
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing);
auto widthActual = ((width()-20-30)/maximum())*maximum();
mWidthActual = widthActual;
auto xActual = 10+(width()-20-widthActual)/2;
mXActual = xActual;
auto jump = widthActual/maximum();
mJump = jump;
auto xpos = (jump*value())+xActual;
cursor = new QRectF(xpos,0,mControlSize,mControlSize);
QRectF pilot(xActual,0, widthActual+mControlSize, mControlSize);
painter.setPen(QPen(QColor("#161616")));
painter.setBrush(QBrush(QColor("#240128")));
painter.drawRoundedRect(pilot, mHalfWidth,mHalfWidth);
QRectF highlight;
auto startX = mStart*mJump+mXActual;
if(xpos == startX) {
highlight.setRect(0,0,0,0);
} else if(xpos > startX) {
highlight.setRect(startX,0, xpos+mControlSize-startX, mControlSize);
} else {
highlight.setRect(xpos,0, startX-(xpos)+mControlSize, mControlSize);
}
painter.setBrush(QBrush(QColor("#6E047C")));
QLinearGradient gradient;
gradient.setStart(highlight.width() / 2, 0);
gradient.setFinalStop(highlight.width() / 2, highlight.height());
gradient.setColorAt(0, "#B64FC4");
gradient.setColorAt(1, "#6E047C");
painter.setBrush(QBrush(gradient));
painter.drawRoundedRect(highlight, mHalfWidth,mHalfWidth);
if(mGrabbed) {
painter.setBrush(QBrush(QColor("#D24CE3")));
} else {
painter.setBrush(QBrush(QColor("#8E06A0")));
}
painter.setPen(QPen(QColor("#52015B")));
painter.drawEllipse(*cursor);
painter.setPen(QPen(QColor("#B1B7E6")));
}
示例5: be
/*!
\brief Render the plot to a QSvgGenerator
If the generator has a view box, the plot will be rendered into it.
If it has no viewBox but a valid size the target coordinates
will be (0, 0, generator.width(), generator.height()). Otherwise
the target rectangle will be QRectF(0, 0, 800, 600);
\param plot Plot to be rendered
\param generator SVG generator
*/
void QwtPolarRenderer::renderTo(
QwtPolarPlot *plot, QSvgGenerator &generator ) const
{
QRectF rect = generator.viewBoxF();
if ( rect.isEmpty() )
rect.setRect( 0, 0, generator.width(), generator.height() );
if ( rect.isEmpty() )
rect.setRect( 0, 0, 800, 600 ); // something
QPainter p( &generator );
render( plot, &p, rect );
}
示例6: boundingRect
/*!
\return Bounding rectangle of all samples.
For an empty series the rectangle is invalid.
*/
QRectF QwtPlotIntervalCurve::boundingRect() const
{
QRectF rect = QwtPlotSeriesItem<QwtIntervalSample>::boundingRect();
if ( rect.isValid() && orientation() == Qt::Vertical )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect;
}
示例7: boundingRect
/*!
\return Bounding rectangle of all samples.
For an empty series the rectangle is invalid.
*/
QRectF QwtPlotTradingCurve::boundingRect() const
{
QRectF rect = QwtPlotSeriesItem::boundingRect();
if ( orientation() == Qt::Vertical )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect;
}
示例8: bbox
QRectF PositionCursor::bbox() const
{
QRectF r;
qreal h = _sv->score()->spatium() * 2;
switch(_type) {
case CursorType::LOOP_IN:
r.setRect(_rect.x(), _rect.y(), h, _rect.height());
break;
case CursorType::LOOP_OUT:
r.setRect(_rect.x() - h, _rect.y(), h, _rect.height());
break;
default:
r = _rect;
break;
}
return r.adjusted(-2, -2, 2, 2);
}
示例9: relativeResizeRect
void QgsComposerUtils::relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter )
{
//linearly scale rectToResize relative to the scaling from boundsBefore to boundsAfter
double left = relativePosition( rectToResize.left(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
double right = relativePosition( rectToResize.right(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
double top = relativePosition( rectToResize.top(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
double bottom = relativePosition( rectToResize.bottom(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
rectToResize.setRect( left, top, right - left, bottom - top );
}
示例10: getHandleRect
/***********************************************************************
*Funtion : Get the handle rect
*Return : QRectF handle rect.
*Parameter: handle id.
**********************************************************************/
QRectF SamDrawItemBase::getHandleRect(int iHandleID, QRectF &qrcBondingRect)
{
QRectF qrRect;
// get the center of the handle in logical coords
QPointF qpPoint = getHandle(iHandleID, qrcBondingRect);
/*Set the rect and normalize it*/
qrRect.setRect(qpPoint.rx()-SAMDRAW_TRACKER_POS_OFT, qpPoint.ry()-SAMDRAW_TRACKER_POS_OFT, SAMDRAW_TRACKER_SIZE, SAMDRAW_TRACKER_SIZE);
qrRect = qrRect.normalized();
return qrRect;
}
示例11: drawBackground
void KBBLevelConfigurationPreview::drawBackground(QPainter* painter, const QRectF&)
{
QRectF rectBackground;
// TODO: This is duplication of code from the class KBBScalableGraphicWidget. Try to fix this.
const qreal sW = scene()->width();
const qreal sH = scene()->height();
const qreal wW = width();
const qreal wH = height();
const qreal offset = (sH+sW)/100 ;
if (sH*wW > sW*wH) {
// The widget is larger than the scene
qreal w = wW*sH/wH;
rectBackground.setRect((sW-w)/2-offset, -offset, w + 2*offset, sH + 2*offset);
} else {
// The scene is larger than the widget (or as large)
qreal h = wH*sW/wW;
rectBackground.setRect(-offset, (sH-h)/2-offset, sW + 2*offset, h + 2*offset);
}
m_themeManager->svgRenderer()->render(painter, m_themeManager->elementId(KBBScalableGraphicWidget::background), rectBackground);
}
示例12: paint
void GraphNode::paint(QPainter *painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
{
QPen pen(Qt::black, 2);
QBrush brush(Qt::red);
painter->setPen(pen);
painter->setBrush(brush);
painter->drawEllipse(rect());
painter->drawText(rect(), Qt::AlignCenter, label);
if (!subscript.isEmpty()) {
QRectF subRect;
subRect.setRect(cx - 1.65*r, cy + 1.15*r, 15, 15);
painter->drawText(subRect, Qt::AlignCenter, subscript);
scene()->update(subRect);
}
}
示例13: loadOdfViewbox
QRectF KPathShape::loadOdfViewbox(const KXmlElement & element) const
{
QRectF viewbox;
QString data = element.attributeNS(KOdfXmlNS::svg, "viewBox");
if (! data.isEmpty()) {
data.replace(',', ' ');
QStringList coordinates = data.simplified().split(' ', QString::SkipEmptyParts);
if (coordinates.count() == 4) {
viewbox.setRect(coordinates[0].toDouble(), coordinates[1].toDouble(),
coordinates[2].toDouble(), coordinates[3].toDouble());
}
}
return viewbox;
}
示例14: boundingRect
/*!
\return Bounding rectangle of all samples.
For an empty series the rectangle is invalid.
*/
QRectF QwtPlotBarChart::boundingRect() const
{
const size_t numSamples = dataSize();
if ( numSamples == 0 )
return QwtPlotSeriesItem::boundingRect();
const double baseLine = baseline();
QRectF rect = QwtPlotSeriesItem::boundingRect();
if ( rect.bottom() < baseLine )
rect.setBottom( baseLine );
if ( rect.top() > baseLine )
rect.setTop( baseLine );
if ( rect.isValid() && ( orientation() == Qt::Horizontal ) )
rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
return rect;
}
示例15: mouseMoveEvent
void Note::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
if (m_spaceBarWasPressed) {
event->ignore();
return;
}
if (m_inResize) {
double minWidth = emptyMinWidth;
double minHeight = emptyMinHeight;
QSizeF gripSize = m_resizeGrip->boundingRect().size();
QSizeF minSize = m_graphicsTextItem->document()->size() + gripSize + gripSize;
if (minSize.height() > minHeight) minHeight = minSize.height();
QRectF rect = boundingRect();
rect.moveTopLeft(this->pos());
double oldX1 = rect.x();
double oldY1 = rect.y();
double newX = event->scenePos().x() + m_inResize->resizeOffset().x();
double newY = event->scenePos().y() + m_inResize->resizeOffset().y();
QRectF newR;
if (newX - oldX1 < minWidth) {
newX = oldX1 + minWidth;
}
if (newY - oldY1 < minHeight) {
newY = oldY1 + minHeight;
}
newR.setRect(0, 0, newX - oldX1, newY - oldY1);
prepareGeometryChange();
m_rect = newR;
positionGrip();
event->accept();
return;
}
ItemBase::mouseMoveEvent(event);
}