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


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

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


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

示例1: setChildValues

void QRectFPropertyItem::setChildValues()
{
   if (!m_isSettingChildren)
   {
      m_isSettingChildren = true;

      QRectF v = qvariant_cast<QRectF>(m_metaProperty.read(m_parent->qObject()));

      for (int i = 0; i < m_children.count(); i++)
      {
         QPropertyItem* child = m_children[i];
         QString propertyName = child->name();
         QVariant tval;

         if (propertyName == "X")
         {
            tval = v.x();
         }
         else if (propertyName == "Y")
         {
            tval = v.y();
         }
         else if (propertyName == "Width")
         {
            tval = v.width();
         }
         else if (propertyName == "Height")
         {
            tval = v.height();
         }
         m_model->setData(child->index(), tval);
      }


      m_isSettingChildren = false;
   }
}
开发者ID:calebbuahin,项目名称:QPropertyModel,代码行数:37,代码来源:qrectfpropertyitem.cpp

示例2: draw

void CpuPieMarker::draw(QPainter *p,
    const QwtScaleMap &, const QwtScaleMap &,
    const QRectF &rect) const
{
    const CpuPlot *cpuPlot = (CpuPlot *)plot();

    const QwtScaleMap yMap = cpuPlot->canvasMap(QwtPlot::yLeft);

    const int margin = 5;

    QRect pieRect;
    pieRect.setX(rect.x() + margin);
    pieRect.setY(rect.y() + margin);
    pieRect.setHeight( qRound(yMap.transform(80.0)) );
    pieRect.setWidth( pieRect.height() );

    const int dataType[] = { CpuPlot::User, CpuPlot::System, CpuPlot::Idle };

    int angle = (int)(5760 * 0.75);
    for ( unsigned int i = 0;
        i < sizeof(dataType) / sizeof(dataType[0]); i++ )
    {
        const QwtPlotCurve *curve = cpuPlot->cpuCurve(dataType[i]);
        if ( curve->dataSize() > 0 )
        {
            const int value = (int)(5760 * curve->sample(0).y() / 100.0);

            p->save();
            p->setBrush(QBrush(curve->pen().color(), Qt::SolidPattern));
            if ( value != 0 )
                p->drawPie(pieRect, -angle, -value);
            p->restore();

            angle += value;
        }
    }
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:37,代码来源:cpupiemarker.cpp

示例3: paint

void ChartItem::paint(QPainter *painter)
{
    if (m_bars.count() == 0)
        return;

    qreal minimum = m_bars[0]->value();
    qreal maximum = minimum;

    for (int i = 1; i < m_bars.count(); ++i) {
        minimum = qMin(minimum, m_bars[i]->value());
        maximum = qMax(maximum, m_bars[i]->value());
    }

    if (maximum == minimum)
        return;

    painter->save();

    const QRectF rect = boundingRect();
    
    qreal scale = rect.height()/(maximum - minimum);
    qreal barWidth = rect.width()/m_bars.count();

    for (int i = 0; i < m_bars.count(); ++i) {
        BarItem *bar = m_bars[i];
        qreal barEdge1 = scale * (maximum - bar->value());
        qreal barEdge2 = scale * maximum;
        QRectF barRect(rect.x() + i * barWidth,
                       rect.y() + qMin(barEdge1, barEdge2),
                       barWidth, qAbs(barEdge1 - barEdge2));

        painter->setBrush(bar->color());
        painter->drawRect(barRect);
    }

    painter->restore();
}
开发者ID:qt-training,项目名称:training-material,代码行数:37,代码来源:chartitem.cpp

示例4: draw

/*!
  \brief Draw the spectrogram

  \param painter Painter
  \param xMap Maps x-values into pixel coordinates.
  \param yMap Maps y-values into pixel coordinates.
  \param canvasRect Contents rectangle of the canvas in painter coordinates

  \sa setDisplayMode(), renderImage(),
      QwtPlotRasterItem::draw(), drawContourLines()
*/
void QwtPlotSpectrogram::draw( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect ) const
{
    if ( d_data->displayMode & ImageMode )
        QwtPlotRasterItem::draw( painter, xMap, yMap, canvasRect );

    if ( d_data->displayMode & ContourMode )
    {
        // Add some pixels at the borders
        const int margin = 2;
        QRectF rasterRect( canvasRect.x() - margin, canvasRect.y() - margin,
            canvasRect.width() + 2 * margin, canvasRect.height() + 2 * margin );

        QRectF area = QwtScaleMap::invTransform( xMap, yMap, rasterRect );

        const QRectF br = boundingRect();
        if ( br.isValid() )
        {
            area &= br;
            if ( area.isEmpty() )
                return;

            rasterRect = QwtScaleMap::transform( xMap, yMap, area );
        }

        QSize raster = contourRasterSize( area, rasterRect.toRect() );
        raster = raster.boundedTo( rasterRect.toRect().size() );
        if ( raster.isValid() )
        {
            const QwtRasterData::ContourLines lines =
                renderContourLines( area, raster );

            drawContourLines( painter, xMap, yMap, lines );
        }
    }
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:48,代码来源:qwt_plot_spectrogram.cpp

示例5: fill

void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode) {
        Qt::BrushStyle style = brush.style();
        if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) || (style == Qt::TexturePattern ))
            real_engine->fill(path, s->bgBrush);
    }

    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();

        if (g->coordinateMode() > QGradient::LogicalMode) {
            if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
                QBrush copy = brush;
                QTransform mat = copy.transform();
                mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height());
                copy.setTransform(mat);
                real_engine->fill(path, copy);
                return;
            } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
                QBrush copy = brush;
                QTransform mat = copy.transform();
                QRectF r = path.controlPointRect();
                mat.translate(r.x(), r.y());
                mat.scale(r.width(), r.height());
                copy.setTransform(mat);
                real_engine->fill(path, copy);
                return;
            }
        }
    }

    real_engine->fill(path, brush);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:37,代码来源:qemulationpaintengine.cpp

示例6: QRectF

	QRectF
	FlowDesigner::calculatePortBoundingBox(const Port &p, const QRectF &compBounds) {
		const Component *comp = p.getComponent();
		const std::vector<Port *> &ports = comp->getPorts();

		int pos = 0;

		for (Port *port : ports) {
			if (port->getLocation() == p.getLocation()) {
				if (port != &p) {
					pos++;
				} else break;
			}
		}

	    float xPos = compBounds.x();
		float yPos = compBounds.y() +
			COMPONENT_CORNER_RADIUS + m_fontMetrics.height() * (1.5f + pos);

		switch(p.getLocation()) {
		case PortLocation::TOP: {
			return QRectF(0, 0, 0, 0);
		} break;
		case PortLocation::BOTTOM: {
			return QRectF(0, 0, 0, 0);
		} break;
		case PortLocation::LEFT: {
			xPos += LINK_CIRCLE_OFFSET;
		} break;
		case PortLocation::RIGHT: {
			xPos += compBounds.width() - LINK_CIRCLE_OFFSET - 2 * LINK_CIRCLE_RADIUS;
		} break;
		default: break;
		}

		return QRectF(xPos, yPos, 2 * LINK_CIRCLE_RADIUS, 2 * LINK_CIRCLE_RADIUS);
	}
开发者ID:pfrommerd,项目名称:vlab,代码行数:37,代码来源:FlowDesigner.cpp

示例7: height

QList<MapWidget::Position> MapWidget::getEllipsePositions(int markersHeight, const QRectF &ellipseRect) const
{
    qreal hRadius = ellipseRect.width()/2.0;
    qreal vRadius = ellipseRect.height()/2.0;
    qreal elipseHCenter = ellipseRect.x() + hRadius;
    qreal elipseVCenter = ellipseRect.y() + vRadius;

    QList<MapWidget::Position> positions;

    qreal angle = -M_PI/2.0; //start angle
    int index = 0;
    Q_ASSERT(markersHeight > 0);
    const int maxPositions = height()/markersHeight * 2.0;
    static const qreal MAX_ANGLE = M_PI * 1.5;
    static const qreal STEP = 0.1;
    while (index < maxPositions && angle < MAX_ANGLE) {
        qreal x = elipseHCenter + (std::cos(angle) * hRadius);
        qreal y = elipseVCenter + (std::sin(angle) * vRadius);
        positions.append(MapWidget::Position(QPointF(x, y), index++));
        qreal tempY;
        do{
            angle += STEP;
            tempY = elipseVCenter + (std::sin(angle) * vRadius);
        }
        while (qAbs(tempY - y) <= markersHeight && angle < MAX_ANGLE);
    }

    // the last position is too close to the first position?
    if (positions.size() >= 2) {
        const MapWidget::Position &first = positions.first();
        const MapWidget::Position &last = positions.last();
        if (qAbs(last.coords.y() - first.coords.y()) < markersHeight)
            positions.removeLast(); // discard the last
    }

    return positions;
}
开发者ID:elieserdejesus,项目名称:JamTaba,代码行数:37,代码来源:MapWidget.cpp

示例8: paintRowGrid

void DateTimeGrid::paintRowGrid( QPainter* painter,
                                  const QRectF& /*sceneRect*/,
                                  const QRectF& exposedRect,
                                  AbstractRowController* rowController,
                                  QWidget* /*widget*/ )
{
    if ( rowController && rowSeparators() ) {
        // First draw the rows
        QPen pen = painter->pen();
        pen.setBrush( QApplication::palette().dark() );
        pen.setStyle( Qt::DashLine );
        painter->setPen( pen );
        QModelIndex idx = rowController->indexAt( qRound( exposedRect.top() ) );
        qreal y = 0;
        while ( y < exposedRect.bottom() && idx.isValid() ) {
            const Span s = rowController->rowGeometry( idx );
            y = s.start()+s.length();
            //painter->drawLine( QPointF( sceneRect.left(), y ), QPointF( sceneRect.right(), y ) );
            // Is alternating background better?
            if ( idx.row()%2 ) painter->fillRect( QRectF( exposedRect.x(), s.start(), exposedRect.width(), s.length() ), QApplication::palette().alternateBase() );
            idx =  rowController->indexBelow( idx );
        }
    }
}
开发者ID:KDE,项目名称:calligra-history,代码行数:24,代码来源:kdganttdatetimegrid.cpp

示例9: mouseOverKeyFrames

int AbstractClipItem::mouseOverKeyFrames(QPointF pos, double maxOffset)
{
    const QRectF br = sceneBoundingRect();
    double maxw = br.width() / cropDuration().frames(m_fps);
    double maxh = br.height() / 100.0 * m_keyframeFactor;
    if (m_keyframes.count() > 0) {
        QMap<int, int>::const_iterator i = m_keyframes.constBegin();
        double x1;
        double y1;
        while (i != m_keyframes.constEnd()) {
            x1 = br.x() + maxw * (i.key() - cropStart().frames(m_fps));
            y1 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
            if (qAbs(pos.x() - x1) < maxOffset && qAbs(pos.y() - y1) < 10) {
                setToolTip('[' + QString::number((GenTime(i.key(), m_fps) - cropStart()).seconds(), 'f', 2) + i18n("seconds") + ", " + QString::number(i.value(), 'f', 1) + ']');
                return i.key();
            } else if (x1 > pos.x()) {
                break;
            }
            ++i;
        }
    }
    setToolTip(QString());
    return -1;
}
开发者ID:eddrog,项目名称:kdenlive,代码行数:24,代码来源:abstractclipitem.cpp

示例10: renderItem

/*!
  Render a legend entry into a given rectangle.

  \param painter Painter
  \param widget Widget representing a legend entry
  \param rect Bounding rectangle
  \param fillBackground When true, fill rect with the widget background 

  \note When widget is not derived from QwtLegendLabel renderItem
        does nothing beside the background
*/
void QwtLegend::renderItem( QPainter *painter, 
    const QWidget *widget, const QRectF &rect, bool fillBackground ) const
{
    if ( fillBackground )
    {
        if ( widget->autoFillBackground() ||
            widget->testAttribute( Qt::WA_StyledBackground ) )
        {
            QwtPainter::drawBackgound( painter, rect, widget );
        }
    }

    const QwtLegendLabel *label = qobject_cast<const QwtLegendLabel *>( widget );
    if ( label )
    {
        // icon

        const QwtGraphic &icon = label->data().icon();
        const QSizeF sz = icon.defaultSize();

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

        icon.render( painter, iconRect, Qt::KeepAspectRatio );

        // title

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

        painter->setFont( label->font() );
        painter->setPen( label->palette().color( QPalette::Text ) );
        const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect );
    }
}
开发者ID:151706061,项目名称:sofa,代码行数:47,代码来源:qwt_legend.cpp

示例11: paint

void GenericSurfacePainter::paint(quint8 *data,
        const BufferFormat & frameFormat,
        QPainter *painter,
        const PaintAreas & areas)
{
    Q_ASSERT(m_imageFormat != QImage::Format_Invalid);

    QImage image(
        data,
        frameFormat.frameSize().width(),
        frameFormat.frameSize().height(),
        frameFormat.bytesPerLine(),
        m_imageFormat);

    QRectF sourceRect = areas.sourceRect;
    sourceRect.setX(sourceRect.x() * frameFormat.frameSize().width());
    sourceRect.setY(sourceRect.y() * frameFormat.frameSize().height());
    sourceRect.setWidth(sourceRect.width() * frameFormat.frameSize().width());
    sourceRect.setHeight(sourceRect.height() * frameFormat.frameSize().height());

    painter->fillRect(areas.blackArea1, Qt::black);
    painter->drawImage(areas.videoArea, image, sourceRect);
    painter->fillRect(areas.blackArea2, Qt::black);
}
开发者ID:AaronZJU,项目名称:qgroundcontrol,代码行数:24,代码来源:genericsurfacepainter.cpp

示例12: beginTransparencyLayer

void GraphicsContext::beginTransparencyLayer(float opacity)
{
    if (paintingDisabled())
        return;

    int x, y, w, h;
    x = y = 0;
    QPainter *p = m_data->p();
    const QPaintDevice *device = p->device();
    w = device->width();
    h = device->height();

    QRectF clip = p->clipPath().boundingRect();
    QRectF deviceClip = p->transform().mapRect(clip);
    x = int(qBound(qreal(0), deviceClip.x(), (qreal)w));
    y = int(qBound(qreal(0), deviceClip.y(), (qreal)h));
    w = int(qBound(qreal(0), deviceClip.width(), (qreal)w) + 2);
    h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);

    TransparencyLayer * layer = new TransparencyLayer(m_data->p(), QRect(x, y, w, h));

    layer->opacity = opacity;
    m_data->layers.push(layer);
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:24,代码来源:GraphicsContextQt.cpp

示例13: paintMultiLayer

void ossimGui::ImageScrollWidget::paintWidget(QPainter& painter)
{
   if((m_layers->numberOfLayers() > 1)&&(m_multiLayerAlgorithm!=NO_ALGORITHM))
   {
      paintMultiLayer(painter);
   }
   else 
   {
      ossimRefPtr<Layer> topLayer    = m_layers->layer((ossim_uint32)0);
      if(topLayer.valid())
      {
         ossimRefPtr<StaticTileImageCache> topTileCache = topLayer->tileCache();
         if(topTileCache.valid())
         {
            ossimIrect rect          = topTileCache->getRect();
            QRectF rectF = m_scrollToLocal.mapRect(QRectF(rect.ul().x, rect.ul().y, rect.width(), rect.height()));
            
            ossimIpt topOriginOffset = ossimDpt(rectF.x(), rectF.y());
            painter.drawImage(topOriginOffset.x, topOriginOffset.y, topTileCache->getCache());
         }
      }
   }
   if(!m_trackPoint.hasNans()&&m_trackingFlag&&!m_mouseInsideFlag)
   {
      drawCursor(painter);
   }


   // Temporary marker control
   // if (m_drawPts == true)
   // {
   //    m_regOverlay->drawMeas(painter, m_viewToLocal);
   // }
   // m_regOverlay->drawProj(painter, m_viewToLocal);

}
开发者ID:Dukeke,项目名称:ossim,代码行数:36,代码来源:ImageWidget.cpp

示例14: drawGrid

void OrthogonalRenderer::drawGrid(QPainter *painter, const QRectF &rect,
                                  QColor gridColor) const
{
    const int tileWidth = map()->tileWidth();
    const int tileHeight = map()->tileHeight();

    if (tileWidth <= 0 || tileHeight <= 0)
        return;

    const int startX = qMax(0, (int) (rect.x() / tileWidth) * tileWidth);
    const int startY = qMax(0, (int) (rect.y() / tileHeight) * tileHeight);
    const int endX = qMin(qCeil(rect.right()),
                          map()->width() * tileWidth + 1);
    const int endY = qMin(qCeil(rect.bottom()),
                          map()->height() * tileHeight + 1);

    gridColor.setAlpha(128);

    QPen gridPen(gridColor);
    gridPen.setCosmetic(true);
    gridPen.setDashPattern(QVector<qreal>() << 2 << 2);

    if (startY < endY) {
        gridPen.setDashOffset(startY);
        painter->setPen(gridPen);
        for (int x = startX; x < endX; x += tileWidth)
            painter->drawLine(x, startY, x, endY - 1);
    }

    if (startX < endX) {
        gridPen.setDashOffset(startX);
        painter->setPen(gridPen);
        for (int y = startY; y < endY; y += tileHeight)
            painter->drawLine(startX, y, endX - 1, y);
    }
}
开发者ID:DarthRumata,项目名称:tiled,代码行数:36,代码来源:orthogonalrenderer.cpp

示例15: appendChildNode

GuideLabelNode::GuideLabelNode(QString name, LabelsItem::label_t type)
    :m_textTexture(new QSGSimpleTextureNode), m_name(name)
{
    appendChildNode(&debugRect);
    debugRect.setColor(QColor("green"));
    QColor color;
    switch(type) {
        case LabelsItem::label_t::CONSTEL_NAME_LABEL:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "CNameColor" );
            break;
        case LabelsItem::label_t::HORIZON_LABEL:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "CompassColor" );
            break;
        default:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "UserLabelColor" );
    }

    m_textTexture->setTexture(SkyMapLite::Instance()->textToTexture(name, color));
    m_opacity->appendChildNode(m_textTexture);

    m_textSize = m_textTexture->texture()->textureSize();
    QRectF oldRect = m_textTexture->rect();
    m_textTexture->setRect(QRect(oldRect.x(),oldRect.y(),m_textSize.width(),m_textSize.height()));
}
开发者ID:KDE,项目名称:kstars,代码行数:24,代码来源:guidelabelnode.cpp


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