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


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

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


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

示例1: clipAndDrawPixmap

void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
{
    Q_Q(QBlitterPaintEngine);
    QRectF intersectedRect = clip.intersected(target);
    if (intersectedRect.isEmpty())
        return;
    QRectF source = sr;
    if (intersectedRect.size() != target.size()) {
        if (sr.size() == target.size()) {
            // no resize
            qreal deltaTop = target.top() - intersectedRect.top();
            qreal deltaLeft = target.left() - intersectedRect.left();
            qreal deltaBottom = target.bottom() - intersectedRect.bottom();
            qreal deltaRight = target.right() - intersectedRect.right();
            source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
        } else {
            // resize case
            qreal hFactor = sr.size().width() / target.size().width();
            qreal vFactor = sr.size().height() / target.size().height();
            qreal deltaTop = (target.top() - intersectedRect.top()) * vFactor;
            qreal deltaLeft = (target.left() - intersectedRect.left()) * hFactor;
            qreal deltaBottom = (target.bottom() - intersectedRect.bottom()) * vFactor;
            qreal deltaRight = (target.right() - intersectedRect.right()) * hFactor;
            source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
        }
    }
    pmData->unmarkRasterOverlay(intersectedRect);
    if (opacity)
        pmData->blittable()->drawPixmapOpacity(intersectedRect, pm, source, q->state()->compositionMode(), q->state()->opacity);
    else
        pmData->blittable()->drawPixmap(intersectedRect, pm, source);
}
开发者ID:13W,项目名称:phantomjs,代码行数:32,代码来源:qpaintengine_blitter.cpp

示例2: boundingRect

QRectF UBGraphicsPathItem::boundingRect() const
{
    QRectF rect = path().boundingRect();

    int enlarge = 0;


    if (strokeProperty())
    {
        int thickness = strokeProperty()->width();
        enlarge = thickness/2;
    }

    if (mIsInCreationMode)//gérer les poignées aux extrémités
        enlarge += HANDLE_SIZE/2;

    rect.adjust(-enlarge, -enlarge, enlarge, enlarge);

    if(mMultiClickState >= 1){
        qreal r = mHandles.first()->radius();

        rect.adjust(-r, -r, r, r);
    }

    return rect;
}
开发者ID:fincom,项目名称:Sankore-3.1,代码行数:26,代码来源:UBGraphicsPathItem.cpp

示例3: paint

void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
{
    // Draw in view's coordinates
    painter->setWorldMatrixEnabled( false );

    // Draw high-quality items
    //painter->setRenderHint( QPainter::Antialiasing );

    // Get the transformations required to map the text on the viewport
    QTransform viewPortTransform = m_view->viewportTransform();
    QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() );

    if ( m_current )
    {
        painter->setBrush( QBrush( QColor( 244, 102, 146 ) ) );
        painter->setPen( QPen( QColor( 244, 102, 146 ) ) );
    }
    else
    {
        painter->setBrush( QBrush( QColor( 201, 217, 242 ) ) );
        painter->setPen( QPen( QColor( 201, 217, 242 ) ) );
    }

    mapped.adjust( 1, 2, -1, -2 );
    painter->drawRoundedRect( mapped, 10, 10 );

    /* Draw text */

    // Setup the font
    QFont f = painter->font();

    // Get the font metrics
    QFontMetrics fm = painter->fontMetrics();

    // Adjust the drawing rect
    mapped.adjust( 6, 6, -6, -6 );

    painter->setPen( Qt::black );
    /* Draw the title. */
    painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_name, Qt::ElideRight, mapped.width() ) );

    mapped.adjust( 0, 20, 0, 0 );
    QDateTime m_end = m_start.addSecs( m_duration );
    f.setPixelSize( 10 );
    f.setItalic( true );
    painter->setFont( f );

    /* Draw the hours. */
    painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft,
                       fm.elidedText( m_start.toString( "hh:mm" ) + " - " +
                                      m_end.toString( "hh:mm" ),
                                      Qt::ElideRight, mapped.width() ) );
}
开发者ID:cobr123,项目名称:qtVlc,代码行数:53,代码来源:EPGItem.cpp

示例4: FitInstructionInView

void GInstructionView::FitInstructionInView()
{
	if(!m_pInstruction || !m_pInsScene)
		return;
//	setSceneRect(m_pInstruction->BoundingSceneRect());
	fitInView(&m_pInstruction->m_GraphicsItem);

	QRectF SceneRect = sceneRect();
	if(!SceneRect.isValid())
		return;
	// we don't want blank areas at the beginning or at the ending of the G_old_Instruction in the QGraphicsView
	// so here is what we are going to do: we will see what is the viewport coordinate in the scene,...
	// then, we will add 1 or so, and change the scene coordinate so that it corresponds to the beginning/ending of the G_old_Instruction
	fitInView(SceneRect);
	QRect geomView = geometry();
	int Xini = -1;
	int Xfin = geomView.width() - 3;
	if(Xfin <= 2)
		return;
	double Xiniscene = mapToScene(Xini, 0).rx();
	double Xfinscene = mapToScene(Xfin, 0).rx() - m_pInstruction->Duration();
	SceneRect.adjust(- Xiniscene, 0, - Xfinscene, 0);
	setSceneRect(SceneRect);
	fitInView(SceneRect);
}
开发者ID:GaelReinaudi,项目名称:LabExe,代码行数:25,代码来源:GInstructionView.cpp

示例5: scaledBoundingRect

    inline QRectF scaledBoundingRect( double sx, double sy,
        bool scalePens ) const
    {
        if ( sx == 1.0 && sy == 1.0 )
            return d_boundingRect;

        QTransform transform;
        transform.scale( sx, sy );

        QRectF rect;
        if ( scalePens && d_scalablePen )
        {
            rect = transform.mapRect( d_boundingRect );
        }
        else
        {
            rect = transform.mapRect( d_pointRect );

            const double l = qAbs( d_pointRect.left() - d_boundingRect.left() );
            const double r = qAbs( d_pointRect.right() - d_boundingRect.right() );
            const double t = qAbs( d_pointRect.top() - d_boundingRect.top() );
            const double b = qAbs( d_pointRect.bottom() - d_boundingRect.bottom() );

            rect.adjust( -l, -t, r, b );
        }

        return rect;
    }
开发者ID:0vermind,项目名称:NeoLoader,代码行数:28,代码来源:qwt_graphic.cpp

示例6: 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

示例7: Padding

QRectF
dmz::QtCanvasObjectText::_outline_rect () const {

   QRectF rect;

   if (_text.length ()) {

      const int Padding (8);
      QFontMetricsF metrics = qApp->font ();

      rect.setSize (metrics.size (0, _text));

      if (_drawBackground) {

         rect.adjust (-Padding, -Padding, Padding, Padding);
      }

      if (_alignment == Qt::AlignLeft) {

         rect.translate (0, -rect.center ().y ());
      }
      else if (_alignment == Qt::AlignRight) {

         rect.translate (-rect.width (), -rect.center ().y ());
      }
      else {

         rect.translate (-rect.center ());
      }
   }

   return rect;
}
开发者ID:ben-sangster,项目名称:dmz,代码行数:33,代码来源:dmzQtPluginCanvasObjectBasic.cpp

示例8: mousePressEvent

void CSceneWidget::mousePressEvent(QMouseEvent *event)
{
    if(event->button() != Qt::LeftButton)
    {
        QGraphicsView::mousePressEvent(event);
        return;
    }

    if(QGraphicsItem *item = itemAt(event->pos()))
    {
        _currentItem = qgraphicsitem_cast<CGraphicsItem*>(item);

        if(_currentItem != 0 && !_currentItem->isEditMode())
        {
            _currentItem = 0;
            return;
        }

        QRectF rect = _currentItem->sceneBoundingRect();
        rect.adjust(0,0,rect.x() -RESIZE_BOX, rect.y() -RESIZE_BOX);
        QPoint point = mapFromScene(rect.width(),rect.height());

        if(point.x()  < event->pos().x() && point.y() < event->pos().y())
        {
            _resizeBegin = true;
        }

        _offsetMove = event->pos() - item->pos();
    }
    QGraphicsView::mousePressEvent(event);
}
开发者ID:slima4,项目名称:zgui-qt,代码行数:31,代码来源:scenewidget.cpp

示例9: paint

void SelectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    // delay load song info
    loadSong();

    QRectF rect = boundingRect().adjusted(BAR_PAD,BAR_PAD,0 - BAR_PAD,0 - BAR_PAD);

    // draw header
    QRectF rectHead = QRectF(rect.topLeft(),QSizeF(rect.width(),HEAD_HEIGHT));
    painter->fillRect(rectHead,backColor_);

    // draw body
    QRectF rectBody = QRectF(rectHead.bottomLeft(),QSizeF(rect.width(),rect.height() - HEAD_HEIGHT));
    painter->drawPixmap(
                rectBody.left(),rectBody.top(),
                barLeftPixmap_.width(),rectBody.height(),
                barLeftPixmap_);
    painter->drawPixmap(
                rectBody.right() - barRightPixmap_.width(),rectBody.top(),
                barRightPixmap_.width(),rectBody.height(),
                barRightPixmap_);
    painter->drawPixmap(
                rectBody.left() + barLeftPixmap_.width(),rectBody.top(),
                rectBody.width() - barLeftPixmap_.width() - barRightPixmap_.width(),rectBody.height(),
                barMidPixmap_);

    rectBody.adjust(BAR_MARGIN,BAR_MARGIN,0 - BAR_MARGIN,0 - BAR_MARGIN);

    painter->setFont(QFont(Ts::GUI_FONT_NAME,15));
    if (rect_.width() == Ts::BAR_EXPAND)
    {
        painter->setPen(foreColor_);
        painter->drawText(rectHead,Qt::AlignCenter,QString("%1/%2").arg(index_).arg(total_));

        painter->setPen(Qt::black);
        painter->drawText(
                    rectBody.right() - 30,rectBody.top(),30,rectBody.height(),
                    Qt::AlignHCenter,title_);
        painter->drawText(
                    rectBody.right() - 60,rectBody.top(),30,rectBody.height(),
                    Qt::AlignHCenter | Qt::AlignBottom,subTitle_);

        // show courses
        courses_.show();

    }
    else
    {
        painter->setPen(foreColor_);
        painter->drawText(rectHead,Qt::AlignCenter,QString::number(index_));

        painter->setPen(Qt::black);
        painter->drawText(rectBody,Qt::AlignCenter,title_);

        courses_.hide();
    }
}
开发者ID:ShikyC,项目名称:taikosanro,代码行数:60,代码来源:selectitem.cpp

示例10: getQPainterCheckersInfo

void KisCoordinatesConverter::getQPainterCheckersInfo(QTransform *transform,
                                                      QPointF *brushOrigin,
                                                      QPolygonF *polygon) const
{
    /**
     * Qt has different rounding for QPainter::drawRect/drawImage.
     * The image is rounded mathematically, while rect in aligned
     * to the next integer. That causes transparent line appear on
     * the canvas.
     *
     * See: https://bugreports.qt.nokia.com/browse/QTBUG-22827
     */

    QRectF imageRect = imageRectInViewportPixels();
    imageRect.adjust(0,0,-0.5,-0.5);

    KisConfig cfg;
    if (cfg.scrollCheckers()) {
        *transform = viewportToWidgetTransform();
        *polygon = imageRect;
        *brushOrigin = imageToViewport(QPointF(0,0));
    }
    else {
        *transform = QTransform();
        *polygon = viewportToWidgetTransform().map(imageRect);
        *brushOrigin = QPoint(0,0);
    }
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:28,代码来源:kis_coordinates_converter.cpp

示例11: mouseMoveEvent

void MContainerHeaderView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    Q_UNUSED(event);
    style().setModeDefault();

    if (!expectMouseReleaseEvent) {
        return;
    }

    QPointF touch = event->scenePos();
    qreal distanceFromPressPoint = (touch - pressScenePos).manhattanLength();

    QRectF rect = controller->sceneBoundingRect();
    rect.adjust(-M_RELEASE_MISS_DELTA, -M_RELEASE_MISS_DELTA,
                M_RELEASE_MISS_DELTA, M_RELEASE_MISS_DELTA);

    if (distanceFromPressPoint > style()->maxDistanceForClick() || !rect.contains(touch)) {
        // Too far: cancel
        expectMouseReleaseEvent = false;
        QApplication::postEvent(controller, new MCancelEvent);
        return;
    }

    update();
}
开发者ID:arcean,项目名称:libmeegotouch-framework,代码行数:25,代码来源:mcontainerheader.cpp

示例12: setCurrentItem

void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
{
    QGraphicsItem *prevItem = m_currentItem;
    m_currentItem = item;

    if (!m_currentItem)
        return;

    QRect viewRect = m_inspector->declarativeView()->rect();
    viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();

    QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
    itemRect = item->mapRectToScene(itemRect);

    // if updating the same item as before, resize the rectangle only bigger, not smaller.
    if (prevItem == item && prevItem != 0) {
        m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect);
    } else {
        m_itemPolyRect = itemRect;
    }
    QRectF borderRect = m_itemPolyRect;
    borderRect.adjust(-1, -1, 1, 1);
    m_borderRect->setRect(borderRect);

    const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect());
    setPolygon(regionToPolygon(externalRegion));
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:27,代码来源:subcomponentmasklayeritem.cpp

示例13: boundingRect

QRectF ArrowItem::boundingRect() const
{
    QRectF br = p.boundingRect();
    qreal pw = pen().widthF();
    br.adjust(-pw/2, -pw/2, pw/2, pw/2);
    return t.mapRect(br);
}
开发者ID:ElectronicRU,项目名称:iceberg-simulator,代码行数:7,代码来源:graphics.cpp

示例14: paintSamplesArrow

void DesignerGUIUtils::paintSamplesArrow(QPainter* painter) {
    QPen pen(Qt::darkGray);
    pen.setWidthF(2);
    painter->setPen(pen);
    painter->setRenderHint(QPainter::SmoothPixmapTransform);
    QFont f = painter->font();
    painter->resetTransform();
    f.setFamily("Times New Roman");
    f.setPointSizeF(20);
    f.setItalic(true);
    painter->setFont(f);

    QRectF approx(50,50, 400, 400);
    QString txt = QObject::tr("Select a sample to start");
    QRectF res = painter->boundingRect(approx, Qt::AlignLeft | Qt::AlignTop, txt);
    res.adjust(-5,-3,15,3);

    QPainterPath p(QPointF(5, res.center().y()));
    p.lineTo(res.topLeft());
    p.lineTo(res.topRight());
    p.lineTo(res.bottomRight());
    p.lineTo(res.bottomLeft());
    p.closeSubpath();
    QColor yc = QColor(255,255,160);//QColor(Qt::yellow).lighter();yc.setAlpha(127);
    painter->fillPath(p, QBrush(yc));
    painter->drawPath(p);
    painter->setPen(Qt::black);
    painter->drawText(approx, Qt::AlignLeft | Qt::AlignTop, txt);
}
开发者ID:m-angelov,项目名称:ugene,代码行数:29,代码来源:WorkflowGUIUtils.cpp

示例15: editedRoleChanged

void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const QByteArray& previous)
{
    Q_UNUSED(previous);

   QGraphicsView* parent = scene()->views()[0];
   if (current.isEmpty() || !parent || current != "text") {
        if (m_roleEditor) {
            emit roleEditingCanceled(index(), current, data().value(current));

            disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
                       this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
            disconnect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
                       this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
            m_roleEditor->deleteLater();
            m_roleEditor = 0;
        }
        return;
    }

    Q_ASSERT(!m_roleEditor);

    const TextInfo* textInfo = m_textInfo.value("text");

    m_roleEditor = new KItemListRoleEditor(parent);
    m_roleEditor->setIndex(index());
    m_roleEditor->setRole(current);
    m_roleEditor->setFont(styleOption().font);

    const QString text = data().value(current).toString();
    m_roleEditor->setPlainText(text);

    QTextOption textOption = textInfo->staticText.textOption();
    m_roleEditor->document()->setDefaultTextOption(textOption);

    const int textSelectionLength = selectionLength(text);

    if (textSelectionLength > 0) {
        QTextCursor cursor = m_roleEditor->textCursor();
        cursor.movePosition(QTextCursor::StartOfBlock);
        cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, textSelectionLength);
        m_roleEditor->setTextCursor(cursor);
    }

    connect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
            this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
    connect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
            this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));

    // Adjust the geometry of the editor
    QRectF rect = roleEditingRect(current);
    const int frameWidth = m_roleEditor->frameWidth();
    rect.adjust(-frameWidth, -frameWidth, frameWidth, frameWidth);
    rect.translate(pos());
    if (rect.right() > parent->width()) {
        rect.setWidth(parent->width() - rect.left());
    }
    m_roleEditor->setGeometry(rect.toRect());
    m_roleEditor->show();
    m_roleEditor->setFocus();
}
开发者ID:theunbelievablerepo,项目名称:dolphin2.1,代码行数:60,代码来源:kstandarditemlistwidget.cpp


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