本文整理汇总了C++中QMenuItem::widget方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuItem::widget方法的具体用法?C++ QMenuItem::widget怎么用?C++ QMenuItem::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuItem
的用法示例。
在下文中一共展示了QMenuItem::widget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeTitle
void KPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text)
{
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
((KPopupTitle *)item->widget())->setTitle(text, &icon);
else
qWarning("KPopupMenu: changeTitle() called with non-title id %d.", id);
}
else
qWarning("KPopupMenu: changeTitle() called with invalid id %d.", id);
}
示例2: titlePixmap
QPixmap KPopupMenu::titlePixmap(int id) const
{
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
return(((KPopupTitle *)item->widget())->icon());
else
qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id);
}
else
qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id);
QPixmap tmp;
return(tmp);
}
示例3: title
QString KPopupMenu::title(int id) const
{
if(id == -1) // obsolete
return(d->m_lastTitle);
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
return(((KPopupTitle *)item->widget())->title());
else
qWarning("KPopupMenu: title() called with non-title id %d.", id);
}
else
qWarning("KPopupMenu: title() called with invalid id %d.", id);
return(QString::null);
}
示例4: updateTitle
//static
bool KexiContextMenuUtils::updateTitle(QPopupMenu *menu, const QString& objectName,
const QString& objectTypeName, const QString& iconName)
{
if (!menu || objectName.isEmpty() || objectTypeName.isEmpty())
return false;
const int id = menu->idAt(0);
QMenuItem *item = menu->findItem(id);
if (!item)
return false;
KPopupTitle *title = dynamic_cast<KPopupTitle *>(item->widget());
if (!title)
return false;
/*! @todo look at makeFirstCharacterUpperCaseInCaptions setting [bool]
(see doc/dev/settings.txt) */
QString realTitle( i18n("Object name : Object type", "%1 : %2")
.arg( objectName[0].upper() + objectName.mid(1) )
.arg( objectTypeName ));
if (iconName.isEmpty())
title->setTitle(realTitle);
else {
QPixmap pixmap(SmallIcon( iconName ));
title->setTitle(realTitle, &pixmap);
}
return true;
}