本文整理汇总了C++中QMenuItem::text方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuItem::text方法的具体用法?C++ QMenuItem::text怎么用?C++ QMenuItem::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuItem
的用法示例。
在下文中一共展示了QMenuItem::text方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeItem
void QMenuData::changeItem( int id, const QPixmap &pixmap )
{
QMenuData *parent;
QMenuItem *mi = findItem( id, &parent );
if ( mi ) { // item found
register QPixmap *i = mi->pixmap_data;
bool fast_refresh = i != 0 &&
i->width() == pixmap.width() &&
i->height() == pixmap.height() &&
!mi->text();
if ( !mi->text_data.isNull() ) // delete text
mi->text_data = QString::null;
mi->pixmap_data = new QPixmap( pixmap );
delete i; // old mi->pixmap_data, could be &pixmap
if ( fast_refresh )
parent->updateItem( id );
else
parent->menuContentsChanged();
}
}
示例2: 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() );
//.........这里部分代码省略.........
示例3: slotSelectedLayout
void PMShell::slotSelectedLayout( int id )
{
QMenuItem* menu = m_pViewLayoutsAction->popupMenu( )->findItem( id );
PMViewLayoutManager::theManager( )->displayLayout( menu->text( ), this );
}
示例4: text
QString QMenuData::text( int id ) const
{
QMenuItem *mi = findItem( id );
return mi ? mi->text() : QString::null;
}
示例5: drawContents
void KMenuBar::drawContents(QPainter *p)
{
// Closes the BR77113
// We need to overload this method to paint only the menu items
// This way when the KMenuBar is embedded in the menu applet it
// integrates correctly.
//
// Background mode and origin are set so late because of styles
// using the polish() method to modify these settings.
//
// Of course this hack can safely be removed when real transparency
// will be available
if(!d->topLevel)
{
QMenuBar::drawContents(p);
}
else
{
bool up_enabled = isUpdatesEnabled();
BackgroundMode bg_mode = backgroundMode();
BackgroundOrigin bg_origin = backgroundOrigin();
setUpdatesEnabled(false);
setBackgroundMode(X11ParentRelative);
setBackgroundOrigin(WindowOrigin);
p->eraseRect(rect());
erase();
QColorGroup g = colorGroup();
bool e;
for(int i = 0; i < (int)count(); i++)
{
QMenuItem *mi = findItem(idAt(i));
if(!mi->text().isNull() || mi->pixmap())
{
QRect r = itemRect(i);
if(r.isEmpty() || !mi->isVisible())
continue;
e = mi->isEnabledAndVisible();
if(e)
g = isEnabled() ? (isActiveWindow() ? palette().active() : palette().inactive()) : palette().disabled();
else
g = palette().disabled();
bool item_active = (actItem == i);
p->setClipRect(r);
if(item_active)
{
QStyle::SFlags flags = QStyle::Style_Default;
if(isEnabled() && e)
flags |= QStyle::Style_Enabled;
if(item_active)
flags |= QStyle::Style_Active;
if(item_active && actItemDown)
flags |= QStyle::Style_Down;
flags |= QStyle::Style_HasFocus;
style().drawControl(QStyle::CE_MenuBarItem, p, this, r, g, flags, QStyleOption(mi));
}
else
{
style().drawItem(p, r, AlignCenter | AlignVCenter | ShowPrefix, g, e, mi->pixmap(), mi->text());
}
}
}
setBackgroundOrigin(bg_origin);
setBackgroundMode(bg_mode);
setUpdatesEnabled(up_enabled);
}
}