本文整理汇总了C++中QMenuItem::isEnabledAndVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuItem::isEnabledAndVisible方法的具体用法?C++ QMenuItem::isEnabledAndVisible怎么用?C++ QMenuItem::isEnabledAndVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuItem
的用法示例。
在下文中一共展示了QMenuItem::isEnabledAndVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}