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


C++ QStyleOptionFrame类代码示例

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


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

示例1: p

void PanelKMenu::paintEvent(QPaintEvent * e)
{
    if (sidePixmap.isNull()) {
        PanelServiceMenu::paintEvent(e);
        return;
    }

    QPainter p(this);
    p.setClipRegion(e->region());

    QStyleOptionFrame frOpt;
    frOpt.init(this);
    frOpt.lineWidth    = frameWidth();
    frOpt.midLineWidth = 0;
    style()->drawPrimitive( QStyle::PE_FrameMenu, &frOpt, &p, this);

    QRect r = sideImageRect();
    r.setBottom( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        p.drawTiledPixmap( r, sideTilePixmap );
    }

    r = sideImageRect();
    r.setTop( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() );
        QRect pixRect = drawRect;
        pixRect.translate( -r.left(), -r.top() );
        p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
    }

    PanelServiceMenu::paintEvent( e );
}
开发者ID:jschwartzenberg,项目名称:kicker,代码行数:35,代码来源:k_mnu.cpp

示例2: Q_UNUSED

/*! \reimp */
void QDockWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QDockWidgetLayout *layout
        = qobject_cast<QDockWidgetLayout*>(this->layout());
    bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
    bool nativeDeco = layout->nativeWindowDeco();

    if (!nativeDeco && !customTitleBar) {
        QStylePainter p(this);
        // ### Add PixelMetric to change spacers, so style may show border
        // when not floating.
        if (isFloating()) {
            QStyleOptionFrame framOpt;
            framOpt.init(this);
            p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
        }

        // Title must be painted after the frame, since the areas overlap, and
        // the title may wish to extend out to all sides (eg. XP style)
        QStyleOptionDockWidgetV2 titleOpt;
        initStyleOption(&titleOpt);
        p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
    }
}
开发者ID:phen89,项目名称:rtqt,代码行数:27,代码来源:qdockwidget.cpp

示例3: style

void KSelector::paintEvent( QPaintEvent * )
{
  QPainter painter;
  int w = style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
  int iw = (w < ARROWSIZE) ? ARROWSIZE : w;

  painter.begin( this );

  drawContents( &painter );

  QBrush brush;

  QPoint pos = calcArrowPos( value() );
  drawArrow( &painter, pos );

  if ( indent() )
  {
    QStyleOptionFrame opt;
    opt.initFrom( this );
    opt.state = QStyle::State_Sunken;
    if ( orientation() == Qt::Vertical )
      opt.rect.adjust( 0, iw - w, -5, w - iw );
    else
      opt.rect.adjust(iw - w, 0, w - iw, -5);
    style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this );
  }


  painter.end();
}
开发者ID:FaizaGara,项目名称:lima,代码行数:30,代码来源:kselector.cpp

示例4: p

void PsiTipLabel::paintEvent(QPaintEvent *)
{
	QStylePainter p(this);
	QStyleOptionFrame opt;
	opt.init(this);
	p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
	p.end();

	// stolen from QLabel::paintEvent
	QPainter painter(this);
	drawFrame(&painter);
	QRect cr = contentsRect();
	cr.adjust(margin, margin, -margin, -margin);

	PsiRichText::ensureTextLayouted(doc, width() - 2*margin);
	QAbstractTextDocumentLayout *layout = doc->documentLayout();
	// QRect lr = rect();
	QRect lr = cr;

	QAbstractTextDocumentLayout::PaintContext context;

	// Adjust the palette
	context.palette = palette();
	if (foregroundRole() != QPalette::Text && isEnabled())
		context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));

	painter.save();
	painter.translate(lr.x() + 1, lr.y() + 1);
	painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1));
	layout->draw(&painter, context);
	painter.restore();
}
开发者ID:AlekSi,项目名称:psi,代码行数:32,代码来源:psitiplabel.cpp

示例5: fm

void MultiLineEdit::updateSizeHint()
{
    QFontMetrics fm(font());
    int minPixelHeight = fm.lineSpacing() * _minHeight;
    int maxPixelHeight = fm.lineSpacing() * _maxHeight;
    int scrollBarHeight = horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0;

    // use the style to determine a decent size
    int h = qMin(qMax((int)document()->size().height() + scrollBarHeight, minPixelHeight), maxPixelHeight) + 2 * frameWidth();

    QStyleOptionFrame opt;
    opt.initFrom(this);
    opt.rect = QRect(0, 0, 100, h);
    opt.lineWidth = lineWidth();
    opt.midLineWidth = midLineWidth();
    opt.state |= QStyle::State_Sunken;
    QWidget* widget = this;
#ifdef Q_OS_MAC
    widget = 0;
#endif
    QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h).expandedTo(QApplication::globalStrut()), widget);
    if (s != _sizeHint) {
        _sizeHint = s;
        updateGeometry();
    }
}
开发者ID:fuzzball81,项目名称:quassel,代码行数:26,代码来源:multilineedit.cpp

示例6: CCONTAINER_draw_border

void CCONTAINER_draw_border(QPainter *p, char frame, QWidget *wid)
{
	QStyleOptionFrame opt;
	opt.init(wid);
	opt.rect = QRect(0, 0, wid->width(), wid->height());
	_draw_border(p, frame, wid, opt);
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:7,代码来源:CContainer.cpp

示例7: Q_D

/*!
    \internal

    Used by QLabel and QLCDNumber
 */
void QFrame::drawFrame(QPainter *p)
{
    Q_D(QFrame);
    QStyleOptionFrame opt;
    opt.init(this);
    int frameShape  = d->frameStyle & QFrame::Shape_Mask;
    int frameShadow = d->frameStyle & QFrame::Shadow_Mask;
    opt.frameShape = Shape(int(opt.frameShape) | frameShape);
    opt.rect = frameRect();
    switch (frameShape) {
        case QFrame::Box:
        case QFrame::HLine:
        case QFrame::VLine:
        case QFrame::StyledPanel:
        case QFrame::Panel:
            opt.lineWidth = d->lineWidth;
            opt.midLineWidth = d->midLineWidth;
            break;
        default:
            // most frame styles do not handle customized line and midline widths
            // (see updateFrameWidth()).
            opt.lineWidth = d->frameWidth;
            break;
    }

    if (frameShadow == Sunken)
        opt.state |= QStyle::State_Sunken;
    else if (frameShadow == Raised)
        opt.state |= QStyle::State_Raised;

    style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:37,代码来源:qframe.cpp

示例8: p

void FakeToolTip::paintEvent(QPaintEvent *)
{
    QStylePainter p(this);
    QStyleOptionFrame opt;
    opt.init(this);
    p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
    p.end();
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:8,代码来源:faketooltip.cpp

示例9: Q_UNUSED

void QxtToolTipPrivate::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);
    QStylePainter painter(this);
    QStyleOptionFrame opt;
    opt.initFrom(this);
    painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
}
开发者ID:edwardoid,项目名称:DarkKnight,代码行数:8,代码来源:qxttooltip.cpp

示例10: p

void ColorButton::paintEvent(QPaintEvent *ev)
{
	QPushButton::paintEvent(ev);
	QPainter p(this);

	// Get contents rectangle
	QStyleOptionButton opt;
	initStyleOption(&opt);
	QRect cRect;
	if(isFlat()) {
		// Fill the entire widget area
		cRect = rect();
	} else {
		// Only fill the contents area
		cRect =
			style()->subElementRect(QStyle::SE_PushButtonContents, &opt, this);
	}
	cRect.adjust(1, 1, -1, -1); // A little larger padding please

	// Colour fill
	if(m_color.alpha() == 255)
		p.fillRect(cRect, m_color);
	else {
		// Separate left and right rectangles
		QRect lRect = cRect;
		lRect.setWidth(lRect.width() / 2 + 1);
		QRect rRect = cRect;
		rRect.setLeft(lRect.right());

		// Fill the left with the solid colour
		p.fillRect(
			lRect, QColor(m_color.red(), m_color.green(), m_color.blue()));

		// Fill the right with the transparent colour on a checkerboard
		drawCheckerboard(p, rRect, 5, Qt::white, QColor(0xCC, 0xCC, 0xCC));
		p.fillRect(rRect, m_color);
	}

	// Sunken frame
	QStyleOptionFrame fOpt;
	fOpt.initFrom(this);
	fOpt.rect = cRect;
	fOpt.features = QStyleOptionFrame::None;
	fOpt.frameShape = QFrame::Panel;
	fOpt.lineWidth = 1;
	fOpt.midLineWidth = 0;
	fOpt.state |= QStyle::State_Sunken;
	style()->drawControl(QStyle::CE_ShapedFrame, &fOpt, &p, this);

	// Fade out when disabled
	if(!isEnabled()) {
		QBrush brush = palette().base();
		QColor col = brush.color();
		col.setAlpha(127); // 50% transparency
		brush.setColor(col);
		p.fillRect(cRect, brush);
	}
}
开发者ID:andrejsavikin,项目名称:mishira,代码行数:58,代码来源:colorbutton.cpp

示例11: painter

void ToolTip::paintEvent(QPaintEvent *event)
{
    QStylePainter painter(this);
    QStyleOptionFrame opt;
    opt.init(this);
    painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
    painter.end();
    QLabel::paintEvent(event);
}
开发者ID:bookdraft,项目名称:QPeerCastYP,代码行数:9,代码来源:tooltip.cpp

示例12: paintEvent

void TabPreview::paintEvent(QPaintEvent* pe)
{
    QStyleOptionFrame opt;
    opt.init(this);

    QStylePainter painter(this);
    painter.setClipRegion(pe->region());
    painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
}
开发者ID:dagsoftware,项目名称:QupZilla,代码行数:9,代码来源:tabpreview.cpp

示例13: painter

void KToolTipWindow::paintEvent(QPaintEvent* event)
{
    QStylePainter painter(this);
    painter.setClipRegion(event->region());
    QStyleOptionFrame option;
    option.init(this);
    painter.drawPrimitive(QStyle::PE_PanelTipLabel, option);
    painter.end();
}
开发者ID:shadeslayer,项目名称:kinfocenter,代码行数:9,代码来源:ktooltipwindow.cpp

示例14: fillBackground

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

示例15: Q_UNUSED

void QgsGradientStopEditor::paintEvent( QPaintEvent *event )
{
  Q_UNUSED( event );
  QPainter painter( this );

  QRect frameRect( rect().x() + MARGIN_X, rect().y(),
                   rect().width() - 2 * MARGIN_X,
                   rect().height() - MARGIN_BOTTOM );

  //draw frame
  QStyleOptionFrame option;
  option.initFrom( this );
  option.state = hasFocus() ? QStyle::State_KeyboardFocusChange : QStyle::State_None;
  option.rect = frameRect;
  style()->drawPrimitive( QStyle::PE_Frame, &option, &painter );

  if ( hasFocus() )
  {
    //draw focus rect
    QStyleOptionFocusRect option;
    option.initFrom( this );
    option.state = QStyle::State_KeyboardFocusChange;
    option.rect = frameRect;
    style()->drawPrimitive( QStyle::PE_FrameFocusRect, &option, &painter );
  }

  //start with the checkboard pattern
  QBrush checkBrush = QBrush( transparentBackground() );
  painter.setBrush( checkBrush );
  painter.setPen( Qt::NoPen );

  QRect box( frameRect.x() + FRAME_MARGIN, frameRect.y() + FRAME_MARGIN,
             frameRect.width() - 2 * FRAME_MARGIN,
             frameRect.height() - 2 * FRAME_MARGIN );

  painter.drawRect( box );

  // draw gradient preview on top of checkerboard
  for ( int i = 0; i < box.width() + 1; ++i )
  {
    QPen pen( mGradient.color( static_cast< double >( i ) / box.width() ) );
    painter.setPen( pen );
    painter.drawLine( box.left() + i, box.top(), box.left() + i, box.height() + 1 );
  }

  // draw stop markers
  int markerTop = frameRect.bottom() + 1;
  drawStopMarker( painter, QPoint( box.left(), markerTop ), mGradient.color1(), mSelectedStop == 0 );
  drawStopMarker( painter, QPoint( box.right(), markerTop ), mGradient.color2(), mSelectedStop == mGradient.count() - 1 );
  int i = 1;
  Q_FOREACH ( const QgsGradientStop& stop, mStops )
  {
    int x = stop.offset * box.width() + box.left();
    drawStopMarker( painter, QPoint( x, markerTop ), stop.color, mSelectedStop == i );
    ++i;
  }
开发者ID:wongjimsan,项目名称:QGIS,代码行数:56,代码来源:qgsgradientstopeditor.cpp


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