当前位置: 首页>>代码示例>>C++>>正文


C++ QRectF::setX方法代码示例

本文整理汇总了C++中QRectF::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setX方法的具体用法?C++ QRectF::setX怎么用?C++ QRectF::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QRectF的用法示例。


在下文中一共展示了QRectF::setX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:4nykey,项目名称:rockbox,代码行数:54,代码来源:rbalbumart.cpp

示例2: paint

void ZLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
	QPainterPath path;
	path.setFillRule(Qt::WindingFill);

	path.moveTo(m_BRect.x(), m_BRect.y());
	path.lineTo(m_BRect.x()+m_BRect.width()/2, m_BRect.y());

	QRectF rect = m_BRect;
	rect.setX(rect.x()+rect.width()/2);

	path.arcTo(rect, 90, -180);
	path.lineTo(m_BRect.x(), m_BRect.y()+m_BRect.height());

	painter->setPen(QPen(Qt::black, 0) );
	painter->drawPath(path);

    if(option->state & QStyle::State_Selected) {
        painter->setPen(Qt::NoPen);
        QColor lightGray(192, 192, 192, 128);
        painter->setBrush(lightGray);
        painter->drawPath(path);
    }
    else {
    	painter->setPen(Qt::NoPen);
        QColor lightGray(128, 128, 128, 128);
        painter->setBrush(lightGray);
        painter->drawPath(path);
    }
    QFont font; font.setPixelSize(18);
    painter->setPen(QPen(Qt::black, 0));
    painter->setFont(font);

    painter->drawText(m_BRect, Qt::AlignCenter, QString::number(m_iZLayer) );
}
开发者ID:ANNetGPGPU,项目名称:ANNetGPGPU,代码行数:34,代码来源:QZLabel.cpp

示例3: zoomSync

void PlotZoomer::zoomSync(const QRectF &rect)
{
  if (!_ignoreSync)
  {
//    if (QwtPlotZoomer *zoomer = qobject_cast<QwtPlotZoomer *>(sender()))
//    {
//      setZoomStack(zoomer->zoomStack(), zoomer->zoomRectIndex());
//    }
//    else
//    {
//      zoom(rect);
//    }
    // Adjust the zoom rect according to the zoom mode.
    QRectF adjustedRect = rect;
    switch (_zoomMode)
    {
    default:
    case ZoomBoth:
      break;
    case ZoomX:
      adjustedRect.setY(zoomRect().y());
      adjustedRect.setHeight(zoomRect().height());
      break;
    case ZoomY:
      adjustedRect.setX(zoomRect().x());
      adjustedRect.setWidth(zoomRect().width());
      break;
    }
    zoom(adjustedRect);
  }
}
开发者ID:KazNX,项目名称:ocurves,代码行数:31,代码来源:plotzoomer.cpp

示例4: renderBubble

void Playground::renderBubble(int x, int y, GLuint color)
{
    QRectF rect;
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(bubbleSize);
    rect.setWidth(bubbleSize);
    drawTexture(rect, color);
    /*glBindTexture( GL_TEXTURE_2D, color);

    glBegin( GL_QUADS );

    glTexCoord2i( 0, 0 );
    glVertex3f( x, y, 0);

    glTexCoord2i( 1, 0 );
    glVertex3f( x + bubbleSize, y, 0);

    glTexCoord2i( 1, 1 );
    glVertex3f( x + bubbleSize, y + bubbleSize, 0);

    glTexCoord2i( 0, 1 );
    glVertex3f( x, y + bubbleSize, 0);
    glEnd();*/
}
开发者ID:geckoxx,项目名称:yasg,代码行数:25,代码来源:playground.cpp

示例5: brush

void ArrowAlu3::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QFont font = painter->font() ;

    painter->setPen(Qt::black);
    font.setPixelSize(13);
    painter->setFont(font);

    QRectF rect = boundingRect();
    rect.setX(rect.x()+22);
    rect.setY(rect.y()-4);
    rect.setHeight(15);
    rect.setWidth(100);

    painter->drawText(rect,Qt::AlignLeft," ALU 3");

    if(!this->isActive) {
        QBrush brush(QColor(150, 150, 150,255));

        painter->setPen(Qt::NoPen);
        painter->setBrush(notActiveColor);
        painter->drawPolygon(polygon());
    } else {
        QBrush brush(QColor(255, 174, 201,255));

        painter->setPen(Qt::NoPen);
        painter->setBrush(activeColor);
        painter->drawPolygon(polygon());
    }
}
开发者ID:ec-m,项目名称:processorsimulation,代码行数:30,代码来源:arrowalu3.cpp

示例6: paintBackground

void BasicBlockItem::paintBackground(QPainter& p)
{
  QRectF bgRct = boundingRect();
  QRectF adRct = boundingRect();
  QColor bgClr = QColor(Settings::instance().value(MEDUSA_COLOR_VIEW_BACKGROUND, MEDUSA_COLOR_VIEW_BACKGROUND_DEFAULT).toString());
  QColor adClr = QColor(Settings::instance().value(MEDUSA_COLOR_ADDRESS_BACKGROUND, MEDUSA_COLOR_ADDRESS_BACKGROUND_DEFAULT).toString());
  qreal opacity = 1.0;

  if (_isPress)
  {
    bgClr = Qt::darkBlue;
    opacity = 0.7;
  }

  bgRct.setX(bgRct.x() + _adLen);
  adRct.setWidth(_adLen);

  QBrush bgBrsh(bgClr);
  QBrush adBrsh(adClr);

  setOpacity(opacity);
  p.fillRect(bgRct, bgBrsh);
  p.fillRect(adRct, adBrsh);
  _fx->setColor(bgClr);
  p.drawRect(bgRct);
  p.drawRect(adRct);
}
开发者ID:anat,项目名称:medusa,代码行数:27,代码来源:BasicBlockItem.cpp

示例7: renderLegendItem

/*!
  Print the legend item into a given rectangle.

  \param plot Plot widget
  \param painter Painter
  \param widget Widget representing a legend item
  \param rect Bounding rectangle

  \note When widget is not derived from QwtLegendItem renderLegendItem
        does nothing and needs to be overloaded
*/
void QwtPlotRenderer::renderLegendItem( const QwtPlot *plot,
    QPainter *painter, const QWidget *widget, const QRectF &rect ) const
{
    const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
    if ( item )
    {
        const QRect identifierRect(
            rect.x() + item->margin(), rect.y(),
            item->identifierSize().width(), rect.height() );

        QwtLegendItemManager *itemManger = plot->legend()->find( item );
        if ( itemManger )
        {
            painter->save();
            itemManger->drawLegendIdentifier( painter, identifierRect );
            painter->restore();
        }

        // Label

        QRectF titleRect = rect;
        titleRect.setX( identifierRect.right() + 2 * item->spacing() );

        painter->setFont( item->font() );
        item->text().draw( painter, titleRect );
    }
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:38,代码来源:qwt_plot_renderer.cpp

示例8: alignLegend

/*!
  Align the legend to the canvas
  \param canvasRect Geometry of the canvas
  \param legendRect Maximum geometry for the legend
  \return Geometry for the aligned legend
*/
QRectF QwtPlotLayout::alignLegend( const QRectF &canvasRect,
    const QRectF &legendRect ) const
{
    QRectF alignedRect = legendRect;

    if ( d_data->legendPos == QwtPlot::BottomLegend
        || d_data->legendPos == QwtPlot::TopLegend )
    {
        if ( d_data->layoutData.legend.hint.width() < canvasRect.width() )
        {
            alignedRect.setX( canvasRect.x() );
            alignedRect.setWidth( canvasRect.width() );
        }
    }
    else
    {
        if ( d_data->layoutData.legend.hint.height() < canvasRect.height() )
        {
            alignedRect.setY( canvasRect.y() );
            alignedRect.setHeight( canvasRect.height() );
        }
    }

    return alignedRect;
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:31,代码来源:qwt_plot_layout.cpp

示例9: 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);
}
开发者ID:DaytimeAH,项目名称:DataVisualize,代码行数:30,代码来源:queue.cpp

示例10: getFormFields

static QList<FormField> getFormFields(Poppler::Page *popplerPage)
{
    QList<FormField> formFields;

//QTime t = QTime::currentTime();
    QList<Poppler::FormField*> popplerFormFields = popplerPage->formFields();
//qCritical() << t.msecsTo(QTime::currentTime());
    QSizeF popplerPageSizeF = popplerPage->pageSizeF();
    for (int i = 0; i < popplerFormFields.size(); ++i)
    {
        FormField formField;
        Poppler::FormField* popplerFormField = popplerFormFields.at(i);
        const QRectF popplerFormFieldRect = popplerFormField->rect();
        QRectF formFieldRect;
        formFieldRect.setX(popplerFormFieldRect.x() * popplerPageSizeF.width());
        formFieldRect.setY(popplerFormFieldRect.y() * popplerPageSizeF.height());
        formFieldRect.setWidth((popplerFormFieldRect.right() - popplerFormFieldRect.left()) * popplerPageSizeF.width());
        formFieldRect.setHeight((popplerFormFieldRect.bottom() - popplerFormFieldRect.top()) * popplerPageSizeF.height());
        formField.rect = formFieldRect;
//		if (popplerFormField->type() == Poppler::FormField::FormText)
//			formField.text = static_cast<Poppler::FormFieldText*>(popplerFormField)->text();
        formField.field = popplerFormField;
        formFields << formField;
    }

    return formFields;
}
开发者ID:damoguyan,项目名称:pdfviewer,代码行数:27,代码来源:pageitem.cpp

示例11: boundingRect

QRectF GraphicNetNode::boundingRect() const {
	QRectF bounds;

	qreal height = icon->boundingRect().height() + (2.0 * CLOUD_Y_MARGIN);
	qreal width = icon->boundingRect().width() + (2.0 * CLOUD_X_MARGIN);

	if(addressText->isVisible()){
		width = fmax(width, addressText->boundingRect().width());
		height += addressText->boundingRect().height();
	}

	if(hostnameText->isVisible()){
		width = fmax(width, hostnameText->boundingRect().width());
		height += hostnameText->boundingRect().height();
	}

	if(secondAddrsText->isVisible()){
		width = fmax(width, secondAddrsText->boundingRect().width());
		height += secondAddrsText->boundingRect().height();
	}

	bounds.setX(0);
	bounds.setY(0);

	bounds.setWidth(width);
	bounds.setHeight(height);

	return bounds;
}
开发者ID:sevenbitbyte,项目名称:fctdev,代码行数:29,代码来源:networkgraphics.cpp

示例12: paint

void PieChart::paint(QPainter *painter)
{
    painter->setRenderHints(QPainter::Antialiasing, true);
    //Обчислення області для малювання
    QRectF fillRect = boundingRect();
    if(fillRect.height() > fillRect.width()){
        fillRect.setY(fillRect.y() + (fillRect.height()-fillRect.width())/2);
        fillRect.setHeight(fillRect.width());
    } else {
        fillRect.setX(fillRect.x() + (fillRect.width()-fillRect.height())/2);
        fillRect.setWidth(fillRect.height());
    }
    fillRect.adjust(pStrokePen->width(), pStrokePen->width(), -pStrokePen->width(),
                    -pStrokePen->width());

    //Малювання сегментів
    painter->setPen(pStrokePen->getPen());
    double beginAngle = pAngleOffset;
    double segmentAngle;
    for(PieSlice* i:slicesList){
        painter->setBrush(QBrush(i->color()));
        segmentAngle = 5760.0 * fabs(i->value())/sumSliceValue;
        painter->drawPie(fillRect, beginAngle, segmentAngle);
        beginAngle += segmentAngle;
    }
}
开发者ID:balashVI,项目名称:BVIChart,代码行数:26,代码来源:piechart.cpp

示例13: renderLegendItem

/*!
  Print the legend item into a given rectangle.

  \param painter Painter
  \param widget Widget representing a legend item
  \param rect Bounding rectangle

  \note When widget is not derived from QwtLegendItem renderLegendItem
        does nothing and needs to be overloaded
*/
void QwtPolarRenderer::renderLegendItem( QPainter *painter,
    const QWidget *widget, const QRectF &rect ) const
{
    const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
    if ( item )
    {
        const QSize sz = item->identifierSize();

        const QRectF identifierRect( rect.x() + item->margin(),
            rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() );

        QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item );
        if ( itemManger )
        {
            painter->save();
            painter->setClipRect( identifierRect, Qt::IntersectClip );
            itemManger->drawLegendIdentifier( painter, identifierRect );
            painter->restore();
        }

        // Label

        QRectF titleRect = rect;
        titleRect.setX( identifierRect.right() + 2 * item->spacing() );

        painter->setFont( item->font() );
        item->text().draw( painter, titleRect );
    }
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:39,代码来源:qwt_polar_renderer.cpp

示例14: end

bool PlotZoomer::end(bool ok)
{
  // Code here is taken from QwtPlotZoomer. The only modification is around the _zoomMode handling.
  ok = QwtPlotPicker::end(ok);
  if (!ok)
  {
    return false;
  }

  QwtPlot *plot = QwtPlotZoomer::plot();
  if (!plot)
  {
    return false;
  }

  const QPolygon &pa = selection();
  if (pa.count() < 2)
  {
    return false;
  }

  QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]);
  rect = rect.normalized();

  QRectF currentZoomRect = zoomRect();
  QRectF zoomRect = invTransform(rect).normalized();

  switch (_zoomMode)
  {
  default:
  case ZoomBoth:
    // nothing.
    break;

  case ZoomX:
    // Maintain current zoom y and height.
    zoomRect.setY(currentZoomRect.y());
    zoomRect.setHeight(currentZoomRect.height());
    break;

  case ZoomY:
    // Maintain current zoom x and width.
    zoomRect.setX(currentZoomRect.x());
    zoomRect.setWidth(currentZoomRect.width());
    break;
  }

  const QSizeF minSize = minZoomSize();
  if (minSize.isValid())
  {
    const QPointF center = zoomRect.center();
    zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize()));
    zoomRect.moveCenter(center);
  }

  zoom(zoomRect);

  return true;
}
开发者ID:KazNX,项目名称:ocurves,代码行数:59,代码来源:plotzoomer.cpp

示例15: GetRect

QRectF ItemLocation::GetRect() const {
    QRectF result;
    result.setX(MINIMAP_SIZE * x_ / INVENTORY_SLOTS);
    result.setY(MINIMAP_SIZE * y_ / INVENTORY_SLOTS);
    result.setWidth(MINIMAP_SIZE * w_ / INVENTORY_SLOTS);
    result.setHeight(MINIMAP_SIZE * h_ / INVENTORY_SLOTS);
    return result;
}
开发者ID:Flomeni,项目名称:acquisition,代码行数:8,代码来源:itemlocation.cpp


注:本文中的QRectF::setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。