本文整理汇总了C++中QStyleOption::tabWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QStyleOption::tabWidth方法的具体用法?C++ QStyleOption::tabWidth怎么用?C++ QStyleOption::tabWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStyleOption
的用法示例。
在下文中一共展示了QStyleOption::tabWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawControl
/*! \reimp */
void QCompactStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r,
const QColorGroup &g, SFlags flags, const QStyleOption& opt )
{
switch ( element ) {
case CE_PopupMenuItem:
{
if (! widget || opt.isDefault())
break;
const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
QMenuItem *mi = opt.menuItem();
if ( !mi )
break;
int tab = opt.tabWidth();
int maxpmw = opt.maxIconWidth();
bool dis = !(flags & Style_Enabled);
bool checkable = popupmenu->isCheckable();
bool act = flags & Style_Active;
int x, y, w, h;
r.rect( &x, &y, &w, &h );
QColorGroup itemg = g;
if ( checkable )
maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
int checkcol = maxpmw;
if ( mi && mi->isSeparator() ) { // draw separator
p->setPen( g.dark() );
p->drawLine( x, y, x+w, y );
p->setPen( g.light() );
p->drawLine( x, y+1, x+w, y+1 );
return;
}
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x, y, w, h, fill);
if ( !mi )
return;
if ( mi->isChecked() ) {
if ( act && !dis ) {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Button ) );
} else {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
}
} else if ( !act ) {
p->fillRect(x, y, checkcol , h,
g.brush( QColorGroup::Button ));
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !dis )
mode = QIconSet::Active;
QPixmap pixmap;
if ( checkable && mi->isChecked() )
pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
else
pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
QRect cr( x, y, checkcol, h );
QRect pmr( 0, 0, pixw, pixh );
pmr.moveCenter( cr.center() );
p->setPen( itemg.text() );
p->drawPixmap( pmr.topLeft(), pixmap );
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
} else if ( checkable ) { // just "checking"...
int mw = checkcol + motifItemFrame;
int mh = h - 2*motifItemFrame;
if ( mi->isChecked() ) {
SFlags cflags = Style_Default;
if (! dis)
cflags |= Style_Enabled;
if (act)
cflags |= Style_On;
drawPrimitive( PE_CheckMark, p, QRect(x + motifItemFrame + 2, y + motifItemFrame,
mw, mh), itemg, cflags, opt );
}
}
p->setPen( act ? g.highlightedText() : g.buttonText() );
//.........这里部分代码省略.........