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


C++ QWidget::contentsRect方法代码示例

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


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

示例1: replot

/*!
   Invalidate the paint cache and repaint the canvas
   \sa invalidatePaintCache()
*/
void QwtPlotAbstractGLCanvas::replot()
{
    invalidateBackingStore();
    
    QWidget *w = canvasWidget();
    if ( testPaintAttribute( QwtPlotAbstractGLCanvas::ImmediatePaint ) )
        w->repaint( w->contentsRect() );
    else
        w->update( w->contentsRect() );
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:14,代码来源:qwt_plot_abstract_canvas.cpp

示例2: drawCanvas

void QwtPlotAbstractCanvas::drawCanvas( QPainter *painter )
{
    QWidget *w = canvasWidget();

    painter->save();

    if ( !d_data->styleSheet.borderPath.isEmpty() )
    {
        painter->setClipPath(
            d_data->styleSheet.borderPath, Qt::IntersectClip );
    }
    else
    {
        if ( borderRadius() > 0.0 )
        {
            const QRect frameRect = w->property( "frameRect" ).toRect();
            painter->setClipPath( borderPath2( frameRect ), Qt::IntersectClip );
        }
        else
        {
            painter->setClipRect( w->contentsRect(), Qt::IntersectClip );
        }
    }

    QwtPlot *plot = qobject_cast< QwtPlot *>( w->parent() );
    if ( plot )
        plot->drawCanvas( painter );

    painter->restore();
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:30,代码来源:qwt_plot_abstract_canvas.cpp

示例3: paintEvent

void FlatFrameShadow::paintEvent(QPaintEvent* event ) {
      // this fixes shadows in frames that change frameStyle() after polish()
      if (QFrame* frame = qobject_cast<QFrame*>(parentWidget())) {
            if (frame->frameStyle() != (QFrame::NoFrame))
                  return;
            }
      QWidget* parent = parentWidget();
      QImage pm(size(),  QImage::Format_ARGB32_Premultiplied);

            {
            pm.fill(Qt::transparent);
            QPainter p(&pm);
            p.setClipRegion(event->region());
            p.setRenderHints(QPainter::Antialiasing);
            p.translate(-geometry().topLeft());
            p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
            p.setPen(Qt::NoPen);
            _helper.renderMenuBackground(&p, geometry(), parent, parent->palette());

            // mask
            p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
            p.setBrush(Qt::black);
            p.drawRoundedRect(QRectF(parent->contentsRect()), 2.5, 2.5);
            }

      QPainter p(this);
      p.setClipRegion(event->region());
      p.fillRect(rect(), Qt::transparent);
      p.drawPixmap(QPoint(0, 0), QPixmap::fromImage(pm));
      return;
      }
开发者ID:33akash,项目名称:MuseScore,代码行数:31,代码来源:frameshadow.cpp

示例4: updateGeometry

    //____________________________________________________________________________________
    void FlatFrameShadow::updateGeometry()
    {

        QWidget *widget = parentWidget();
        if( !widget ) return;

        QRect cr = widget->contentsRect();
        switch (shadowArea())
        {

            case Top:
            cr.setHeight( SHADOW_SIZE_TOP-3 );
            break;

            case Bottom:
            cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 4);
            break;

            case Unknown:
            default:
            return;
        }

        setGeometry(cr);
    }
开发者ID:KDE,项目名称:oxygen-transparent,代码行数:26,代码来源:oxygenframeshadow.cpp

示例5: updateGeometry

void SunkenFrameShadow::updateGeometry() {
      QWidget* widget = parentWidget();
      if (!widget)
            return;

      QRect cr = widget->contentsRect();
      switch (shadowArea()) {
            case Top:
                  cr.setHeight( SHADOW_SIZE_TOP );
                  cr.adjust( -1, -1, 1, 0 );
                  break;
            case Left:
                  cr.setWidth(SHADOW_SIZE_LEFT);
                  cr.adjust(-1, SHADOW_SIZE_TOP, 0, -SHADOW_SIZE_BOTTOM);
                  break;
            case Bottom:
                  cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 1);
                  cr.adjust( -1, 0, 1, 1 );
                  break;
            case Right:
                  cr.setLeft(cr.right() - SHADOW_SIZE_RIGHT + 1);
                  cr.adjust(0, SHADOW_SIZE_TOP, 1, -SHADOW_SIZE_BOTTOM);
                  break;
            case UnknownArea:
            default:
                  return;
            }
      setGeometry(cr);
      }
开发者ID:33akash,项目名称:MuseScore,代码行数:29,代码来源:frameshadow.cpp

示例6: paintEvent

    //____________________________________________________________________________________
    void SunkenFrameShadow::paintEvent(QPaintEvent *event )
    {

        // this fixes shadows in frames that change frameStyle() after polish()
        if (QFrame *frame = qobject_cast<QFrame *>(parentWidget()))
        { if (frame->frameStyle() != (QFrame::StyledPanel | QFrame::Sunken)) return; }

        QWidget *parent = parentWidget();
	if(!parent)
	  return;
        QRect r = parent->contentsRect();
        r.translate(mapFromParent(QPoint(0, 0)));

        QColor base( palette().color(QPalette::Window) );
        TileSet::Tiles tiles;
        switch( shadowArea() )
        {
            case Top:
            {
                tiles = TileSet::Left|TileSet::Top|TileSet::Right;
                r.adjust( -2, -2, 2, -1 );
                break;
            }

            case Bottom:
            {
                tiles = TileSet::Left|TileSet::Bottom|TileSet::Right;
                r.adjust( -2, 1, 2, 2 );
                break;
            }

            case Left:
            {
                tiles = TileSet::Left;
                r.adjust( -2, -4, -1, 4 );
                break;
            }

            case Right:
            {
                tiles = TileSet::Right;
                r.adjust( -1, -4, 2, 4 );
                break;
            }

            default: return;
        }

        HoleOptions options( HoleOutline );
        if( _focus ) options |= HoleFocus;
        if( _hover ) options |= HoleHover;
        if( hasContrast() ) options |= HoleContrast;

        QPainter painter(this);
        painter.setClipRegion( event->region() );
        _helper.renderHole( &painter, palette().color( QPalette::Window ), r, options, _opacity, _mode, tiles );

        return;

    }
开发者ID:KDE,项目名称:oxygen-transparent,代码行数:61,代码来源:oxygenframeshadow.cpp

示例7: contentsRect

QRect QWidgetProto::contentsRect() const
{
  QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
  if (item)
    return item->contentsRect();
  return QRect();
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:7,代码来源:qwidgetproto.cpp

示例8: drawStyled

void QwtPlotAbstractCanvas::drawStyled( QPainter *painter, bool hackStyledBackground )
{
    fillBackground( painter );

    if ( hackStyledBackground )
    {
        // Antialiasing rounded borders is done by
        // inserting pixels with colors between the 
        // border color and the color on the canvas,
        // When the border is painted before the plot items
        // these colors are interpolated for the canvas
        // and the plot items need to be clipped excluding
        // the anialiased pixels. In situations, where
        // the plot items fill the area at the rounded
        // borders this is noticeable.
        // The only way to avoid these annoying "artefacts"
        // is to paint the border on top of the plot items.

        if ( !d_data->styleSheet.hasBorder ||
            d_data->styleSheet.borderPath.isEmpty() )
        {
            // We have no border with at least one rounded corner
            hackStyledBackground = false;
        }
    }
    
    QWidget *w = canvasWidget();

    if ( hackStyledBackground )
    {
        painter->save();
        
        // paint background without border
        painter->setPen( Qt::NoPen );
        painter->setBrush( d_data->styleSheet.background.brush );
        painter->setBrushOrigin( d_data->styleSheet.background.origin );
        painter->setClipPath( d_data->styleSheet.borderPath );
        painter->drawRect( w->contentsRect() );

        painter->restore();

        drawCanvas( painter );

        // Now paint the border on top
        QStyleOptionFrame opt;
        opt.initFrom( w );
        w->style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, w);
    }   
    else
    {
        QStyleOption opt;
        opt.initFrom( w );
        w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w );
    
        drawCanvas( painter );
    }   
}   
开发者ID:Au-Zone,项目名称:qwt,代码行数:57,代码来源:qwt_plot_abstract_canvas.cpp

示例9: getRect

static QRect getRect(void *_object)
{
	QWidget *w = CONTAINER;

	if (qobject_cast<MyMainWindow *>(WIDGET))
		((MyMainWindow *)WIDGET)->configure();

	if (qobject_cast<QGroupBox *>(WIDGET))
		return QRect(0, 0, w->width(), w->height());

	return w->contentsRect();
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:12,代码来源:CContainer.cpp

示例10: eventFilter

//! Event filter
bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
{
    if ( event->type() == QEvent::Paint )
    {
        reset();

        if ( d_data->seriesItem )
        {
            const QPaintEvent *pe = static_cast< QPaintEvent *>( event );

            QWidget *canvas = d_data->seriesItem->plot()->canvas();

            QPainter painter( canvas );
            painter.setClipRegion( pe->region() );

            bool doCopyCache = testAttribute( CopyBackingStore );

            if ( doCopyCache )
            {
                QwtPlotCanvas *plotCanvas = 
                    qobject_cast<QwtPlotCanvas *>( canvas );
                if ( plotCanvas )
                {
                    doCopyCache = qwtHasBackingStore( plotCanvas );
                    if ( doCopyCache )
                    {
                        painter.drawPixmap( plotCanvas->contentsRect().topLeft(), 
                            *plotCanvas->backingStore() );
                    }
                }
            }

            if ( !doCopyCache )
            {
                qwtRenderItem( &painter, canvas->contentsRect(),
                    d_data->seriesItem, d_data->from, d_data->to );
            }

            return true; // don't call QwtPlotCanvas::paintEvent()
        }
    }

    return false;
}
开发者ID:OPM,项目名称:ResInsight,代码行数:45,代码来源:qwt_plot_directpainter.cpp

示例11: plot

/*!
  \brief Draw a set of points of a seriesItem.

  When observing an measurement while it is running, new points have to be
  added to an existing seriesItem. drawSeries() can be used to display them avoiding
  a complete redraw of the canvas.

  Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
  will result in faster painting, if the paint engine of the canvas widget
  supports this feature.

  \param seriesItem Item to be painted
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted. If to < 0 the
         series will be painted to its last point.
*/
void QwtPlotDirectPainter::drawSeries(
    QwtPlotSeriesItem *seriesItem, int from, int to )
{
    if ( seriesItem == NULL || seriesItem->plot() == NULL )
        return;

    QWidget *canvas = seriesItem->plot()->canvas();
    const QRect canvasRect = canvas->contentsRect();

    QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas );

    if ( plotCanvas && qwtHasBackingStore( plotCanvas ) )
    {
        QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) );

        if ( d_data->hasClipping )
            painter.setClipRegion( d_data->clipRegion );

        qwtRenderItem( &painter, canvasRect, seriesItem, from, to );

        painter.end();

        if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) )
        {
            plotCanvas->repaint();
            return;
        }
    }

    bool immediatePaint = true;
    if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) ) 
    {
#if QT_VERSION < 0x050000
        if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
#endif
            immediatePaint = false;
    }

    if ( immediatePaint )
    {
        if ( !d_data->painter.isActive() )
        {
            reset();

            d_data->painter.begin( canvas );
            canvas->installEventFilter( this );
        }

        if ( d_data->hasClipping )
        {
            d_data->painter.setClipRegion( 
                QRegion( canvasRect ) & d_data->clipRegion );
        }
        else
        {
            if ( !d_data->painter.hasClipping() )
                d_data->painter.setClipRect( canvasRect );
        }

        qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to );

        if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
        {
            reset();
        }
        else
        {
            if ( d_data->hasClipping )
                d_data->painter.setClipping( false );
        }
    }
    else
    {
        reset();

        d_data->seriesItem = seriesItem;
        d_data->from = from;
        d_data->to = to;

        QRegion clipRegion = canvasRect;
        if ( d_data->hasClipping )
            clipRegion &= d_data->clipRegion;

        canvas->installEventFilter( this );
//.........这里部分代码省略.........
开发者ID:OPM,项目名称:ResInsight,代码行数:101,代码来源:qwt_plot_directpainter.cpp


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