本文整理汇总了C++中QRectF::setHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setHeight方法的具体用法?C++ QRectF::setHeight怎么用?C++ QRectF::setHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doLayout
/**
* 功能
* 当前单元格子元素布局
*/
void WinDigitalDelegate::doLayout(const QStyleOptionViewItem & option, QRectF &valRect, QRectF &unitRect, QRectF &tagRect, QRectF &alarmRect, qreal &alarmSpan) const
{
/***********测量值***********/
valRect = option.rect;
valRect.setHeight(valRect.height()/3);
valRect.moveTop(valRect.bottom());
valRect.setRight(valRect.right() - valRect.width()/18- 3);
/************标记**********/
tagRect = valRect;
tagRect.moveBottom(tagRect.top());
tagRect.setTop(tagRect.top() + option.rect.height()/10);
/************单位***********/
unitRect = valRect;
unitRect.moveTop(unitRect.bottom());
unitRect.setRight(unitRect.right() - 15);
/*************报警标记**********/
alarmRect = unitRect;
alarmRect.setHeight(alarmRect.height()/3);
alarmRect.moveTop(alarmRect.bottom());
alarmRect.setLeft(alarmRect.center().x() - 4*alarmRect.height());
alarmRect.setWidth(alarmRect.height());
alarmSpan = alarmRect.width() * 2;
}
示例2: setSceneRect
void QgsComposerScaleBar::setSceneRect( const QRectF& rectangle )
{
QRectF box = mStyle->calculateBoxSize();
if ( rectangle.height() > box.height() )
{
//keep user specified item height if higher than minimum scale bar height
box.setHeight( rectangle.height() );
}
box.moveTopLeft( rectangle.topLeft() );
//update rect for data defined size and position
QRectF newRect = evalItemRect( rectangle );
//scale bars have a minimum size, respect that regardless of data defined settings
if ( newRect.width() < box.width() )
{
newRect.setWidth( box.width() );
}
if ( newRect.height() < box.height() )
{
newRect.setHeight( box.height() );
}
QgsComposerItem::setSceneRect( newRect );
}
示例3: paint
void NodeInspector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
const auto r = boundingRect().adjusted(border, border, -border, -border);
if (glow)
{
painter->setBrush(Qt::NoBrush);
painter->setPen(QPen(QColor(255, 255, 255, Colors::base02.red()), 20));
painter->drawRoundedRect(r, 8, 8);
}
painter->setBrush(Colors::base01);
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(r, 8, 8);
painter->setBrush(Colors::base03);
QRectF br = title_row->boundingRect();
br.setWidth(r.width());
br.setHeight(br.height() + 2);
painter->drawRoundedRect(br, 8, 8);
br.setHeight(br.height()/2);
br.moveTop(br.height());
painter->drawRect(br);
painter->setBrush(Qt::NoBrush);
if (isSelected())
painter->setPen(QPen(Colors::base05, 2));
else
painter->setPen(QPen(Colors::base03, 2));
painter->drawRoundedRect(r, 8, 8);
}
示例4: setSceneRect
void QgsComposerFrame::setSceneRect( const QRectF &rectangle )
{
QRectF fixedRect = rectangle;
if ( mMultiFrame )
{
//calculate index of frame
int frameIndex = mMultiFrame->frameIndex( this );
QSizeF fixedSize = mMultiFrame->fixedFrameSize( frameIndex );
if ( fixedSize.width() > 0 )
{
fixedRect.setWidth( fixedSize.width() );
}
if ( fixedSize.height() > 0 )
{
fixedRect.setHeight( fixedSize.height() );
}
//check minimum size
QSizeF minSize = mMultiFrame->minFrameSize( frameIndex );
fixedRect.setWidth( qMax( minSize.width(), fixedRect.width() ) );
fixedRect.setHeight( qMax( minSize.height(), fixedRect.height() ) );
}
QgsComposerItem::setSceneRect( fixedRect );
}
示例5: paint
void RBAlbumArt::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QRectF drawArea;
/* Making sure the alignment flags are sane */
if(hAlign != 'c' && hAlign != 'l' && hAlign != 'r')
hAlign = 'c';
if(vAlign != 'c' && vAlign != 't' && vAlign != 'b')
vAlign = 'c';
if(artWidth <= size.width() && artHeight <= size.height())
{
/* If the art is smaller than the viewport, just center it up */
drawArea.setX((size.width() - artWidth) / 2);
drawArea.setY((size.height() - artHeight) / 2);
drawArea.setWidth(artWidth);
drawArea.setHeight(artHeight);
}
else
{
/* Otherwise, figure out our scale factor, and which dimension needs
* to be scaled, and how to align said dimension
*/
double xScale = size.width() / artWidth;
double yScale = size.height() / artHeight;
double scale = xScale < yScale ? xScale : yScale;
double scaleWidth = artWidth * scale;
double scaleHeight = artHeight * scale;
if(hAlign == 'l')
drawArea.setX(0);
else if(hAlign == 'c')
drawArea.setX((size.width() - scaleWidth) / 2 );
else
drawArea.setX(size.width() - scaleWidth);
if(vAlign == 't')
drawArea.setY(0);
else if(vAlign == 'c')
drawArea.setY((size.height() - scaleHeight) / 2);
else
drawArea.setY(size.height() - scaleHeight);
drawArea.setWidth(scaleWidth);
drawArea.setHeight(scaleHeight);
}
painter->fillRect(drawArea, texture);
RBMovable::paint(painter, option, widget);
}
示例6: setSceneRect
void QgsComposerPicture::setSceneRect( const QRectF& rectangle )
{
QSizeF currentPictureSize = pictureSize();
if ( mResizeMode == QgsComposerPicture::Clip )
{
QgsComposerItem::setSceneRect( rectangle );
mPictureWidth = rectangle.width();
mPictureHeight = rectangle.height();
return;
}
QRectF newRect = rectangle;
if ( mResizeMode == ZoomResizeFrame && !rect().isEmpty() && !( currentPictureSize.isEmpty() ) )
{
//if width has changed less than height, then fix width and set height correspondingly
//else, do the opposite
if ( qAbs( rect().width() - rectangle.width() ) <
qAbs( rect().height() - rectangle.height() ) )
{
newRect.setHeight( currentPictureSize.height() * newRect.width() / currentPictureSize.width() );
}
else
{
newRect.setWidth( currentPictureSize.width() * newRect.height() / currentPictureSize.height() );
}
}
else if ( mResizeMode == FrameToImageSize )
{
if ( !( currentPictureSize.isEmpty() ) )
{
newRect.setWidth( currentPictureSize.width() * 25.4 / mComposition->printResolution() );
newRect.setHeight( currentPictureSize.height() * 25.4 / mComposition->printResolution() );
}
}
//find largest scaling of picture with this rotation which fits in item
if ( mResizeMode == Zoom )
{
QRectF rotatedImageRect = largestRotatedRectWithinBounds( QRectF( 0, 0, currentPictureSize.width(), currentPictureSize.height() ), newRect, mPictureRotation );
mPictureWidth = rotatedImageRect.width();
mPictureHeight = rotatedImageRect.height();
}
else
{
mPictureWidth = newRect.width();
mPictureHeight = newRect.height();
}
QgsComposerItem::setSceneRect( newRect );
emit itemChanged();
}
示例7: layoutLegend
QRectF QwtPlotLayout::layoutLegend( Options options,
const QRectF &rect ) const
{
const QSize hint( d_data->layoutData.legend.hint );
int dim;
if ( d_data->legendPos == QwtPlot::LeftLegend
|| d_data->legendPos == QwtPlot::RightLegend )
{
// We don't allow vertical legends to take more than
// half of the available space.
dim = qMin( hint.width(), int( rect.width() * d_data->legendRatio ) );
if ( !( options & IgnoreScrollbars ) )
{
if ( hint.height() > rect.height() )
{
// The legend will need additional
// space for the vertical scrollbar.
dim += d_data->layoutData.legend.vScrollBarWidth;
}
}
}
else
{
dim = qMin( hint.height(), int( rect.height() * d_data->legendRatio ) );
dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
}
QRectF legendRect = rect;
switch ( d_data->legendPos )
{
case QwtPlot::LeftLegend:
legendRect.setWidth( dim );
break;
case QwtPlot::RightLegend:
legendRect.setX( rect.right() - dim );
legendRect.setWidth( dim );
break;
case QwtPlot::TopLegend:
legendRect.setHeight( dim );
break;
case QwtPlot::BottomLegend:
legendRect.setY( rect.bottom() - dim );
legendRect.setHeight( dim );
break;
case QwtPlot::ExternalLegend:
break;
}
return legendRect;
}
示例8: 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;
}
示例9: paint
void GraphBlock::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
QLinearGradient fillBrush( QPointF(0, 0), QPointF(0, m_captionBounds.height()));
fillBrush.setColorAt( 0, isSelected() ? QColor( 255, 226, 96 ) : QColor( 200, 200, 200 ) );
fillBrush.setColorAt( 0.5f, QColor( 70, 70, 70 ) );
painter->save();
painter->setRenderHint( QPainter::Antialiasing, true );
painter->setRenderHint( QPainter::TextAntialiasing, true );
painter->setFont( m_font );
const float edgeRadius = 3.0f;
// draw the block's layout
{
painter->setPen( GraphWidgetUtils::s_borderPen );
painter->setBrush( QColor( 150, 150, 150 ) );
painter->setOpacity( 0.5f );
painter->drawRoundedRect( m_bounds, edgeRadius, edgeRadius );
}
// draw the header
{
QPainterPath path;
QRectF topBB = m_captionBounds;
topBB.setHeight( m_captionBounds.height() + edgeRadius );
QRectF bottomBB = m_captionBounds;
bottomBB.setTop( m_captionBounds.height() );
bottomBB.setHeight( edgeRadius );
path.addRoundedRect( topBB, edgeRadius, edgeRadius );
path.addRect( bottomBB );
painter->setOpacity( 1.0f );
painter->setPen( Qt::NoPen );
painter->setBrush( fillBrush );
painter->drawPath( path );
GraphWidgetUtils::drawShadowedText( painter, m_captionBounds, m_caption.c_str(), QTextOption( Qt::AlignCenter ) );
}
painter->restore();
}
示例10: getSheepRect
QRectF Sheep::getSheepRect(qint32 _len, Qt::Orientation _orientation)
{
QRectF itemRect;
if (Qt::Orientation::Vertical == _orientation)
{
itemRect.setHeight(_len * SceneParams::cellSize);
itemRect.setWidth(SceneParams::cellSize);
}
else
{
itemRect.setHeight(SceneParams::cellSize);
itemRect.setWidth(_len * SceneParams::cellSize);
}
return itemRect;
}
示例11: paint
void QgraphicsItemTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsItemResizable::paint(painter,option,widget);
QPen pen;
pen.setStyle(Qt::DashDotLine);
QPen def = painter->pen();
painter->setPen(pen);
painter->drawRect(boundingRect());
painter->setPen(def);
QRectF bord = boundingRect();
bord.setTop(bord.top()-my);
bord.setLeft(bord.left()-mx);
bord.setWidth(bord.width()-mw);
bord.setHeight(bord.height()-mh);
QRectF *bord2 = new QRectF();
def.setColor(Qt::white);
painter->setPen(def);
painter->drawText(bord,Qt::AlignCenter,*(TableData->GetCaption()),bord2);
qreal px = bord2->left()+TableData->getStrWidth();
qreal py = bord2->top()+TableData->getStrHeight();
bord2->setTop(bord2->top()-5);
bord2->setHeight(bord2->height()+5);
bord2->setLeft(bord2->left()-5);
bord2->setWidth(bord2->width()+5);
painter->fillRect(*bord2,QColor(128,128,128,100));
painter->drawText(bord,Qt::AlignCenter,*(TableData->GetCaption()),bord2);
if (GetgrabRefer()->GrabberItem()==this) painter->drawLine(px,py,px+5,py);
}
示例12: setRowCount
void QGraphicsPickerScene::setRowCount(int rowCount)
{
m_rowCount = rowCount;
QRectF rect = m_selection->rect();
rect.setHeight(sceneRect().height()/rowCount);
m_selection->setRect(rect);
}
示例13: printAreaResized
// slot
void PrintWidget::printAreaResized()
{
QRectF area = map_printer->getPrintArea();
area.setWidth(width_edit->value());
area.setHeight(height_edit->value());
map_printer->setPrintArea(area);
}
示例14: bkgnd
Queue::Queue(QWidget *parent) :
QWidget(parent),
ui(new Ui::Queue)
{
ui->setupUi(this);
QGraphicsScene *scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QPixmap bkgnd(":files/images/bckgnd.png");
bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Background, bkgnd);
this->setPalette(palette);
QRectF coords;
coords.setX(-500); coords.setY(-500);
coords.setWidth(1000); coords.setHeight(1000);
rPoint.setX(-500);
rPoint.setY(-387);
rLineCoords.setLine(-480, -387, -480, -410);
qList = new Ui::List(ui->graphicsView, scene, coords, rPoint, rLineCoords, "Rear");
QFont font;
fPoint.setX(-500);
fPoint.setY(-500);
fLineCoords.setLine(-480, -480, -480, -460);
fLabel = ui->graphicsView->scene()->addText("Front", font);
fLabel->setPos(fPoint);
fLine = ui->graphicsView->scene()->addLine(fLineCoords);
v = new QIntValidator(0, 65535, this);
ui->lineEdit->setValidator(v);
}
示例15: 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();
}