本文整理汇总了C++中QMenuItem::popup方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuItem::popup方法的具体用法?C++ QMenuItem::popup怎么用?C++ QMenuItem::popup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuItem
的用法示例。
在下文中一共展示了QMenuItem::popup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setItemEnabled
void QMenuData::setItemEnabled( int id, bool enable )
{
QMenuData *parent;
QMenuItem *mi = findItem( id, &parent );
if ( mi && (bool)mi->is_enabled != enable ) {
mi->is_enabled = enable;
#ifndef QT_NO_ACCEL
if ( mi->popup() )
mi->popup()->enableAccel( enable );
#endif
parent->menuStateChanged();
}
}
示例2: reduceMenu
QPopupMenu* reduceMenu(QPopupMenu *menu)
{
if (menu->count() != 1)
{
return menu;
}
QMenuItem *item = menu->findItem(menu->idAt(0));
if (item->popup())
{
return reduceMenu(item->popup());
}
return menu;
}
示例3:
static inline QPopupMenu *checkInsertIndex(QPopupMenu *popup, const QStringList& tags, const QString &submenu)
{
int pos = tags.findIndex(submenu);
QPopupMenu *pi = 0;
if (pos != -1)
{
QMenuItem *p = popup->findItem(pos);
pi = p?p->popup():0;
}
if (!pi) pi = popup;
return pi;
}
示例4: 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() );
//.........这里部分代码省略.........