本文整理汇总了C++中QPopupMenu::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QPopupMenu::count方法的具体用法?C++ QPopupMenu::count怎么用?C++ QPopupMenu::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPopupMenu
的用法示例。
在下文中一共展示了QPopupMenu::count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool KSimBaseIntSpinBox::eventFilter(QObject * obj, QEvent * ev)
{
switch(ev->type())
{
case QEvent::MouseButtonPress:
{
if (((QMouseEvent*)ev)->button() == QMouseEvent::RightButton)
{
QPopupMenu * popup = new QPopupMenu(0,"KSimBaseIntSpinBox RMB Popup");
Q_CHECK_PTR(popup);
initRmbMenu(popup);
if (popup->count() != 0)
{
int id = popup->exec(QCursor::pos());
if (id != -1)
{
execRmbMenu(id);
}
}
delete popup;
return true;
}
break;
}
case QEvent::FocusOut:
{
emit undoRequest();
break;
}
default:
break;
}
return KSimSpinBox::eventFilter(obj,ev);
}
示例2: context
void CostTypeView::context(QListViewItem* i, const QPoint & p, int)
{
QPopupMenu popup;
TraceCostType* ct = i ? ((CostTypeItem*) i)->costType() : 0;
if (ct)
popup.insertItem(i18n("Set Secondary Event Type"), 99);
if (_costType2)
popup.insertItem(i18n("Remove Secondary Event Type"), 98);
if (popup.count()>0)
popup.insertSeparator();
if (ct && !ct->isReal()) {
popup.insertItem(i18n("Edit Long Name"), 93);
popup.insertItem(i18n("Edit Short Name"), 94);
popup.insertItem(i18n("Edit Formula"), 95);
popup.insertItem(i18n("Remove"), 96);
popup.insertSeparator();
}
addGoMenu(&popup);
popup.insertSeparator();
popup.insertItem(i18n("New Cost Type ..."), 97);
int r = popup.exec(p);
if (r == 98) selectedCostType2(0);
else if (r == 99) selectedCostType2(ct);
else if (r == 93) i->startRename(0);
else if (r == 94) i->startRename(3);
else if (r == 95) i->startRename(5);
else if (r == 96) {
// search for a previous type
TraceCostType* prev = 0, *ct = 0;
TraceCostMapping* m = _data->mapping();
for (int i=0;i<m->realCount();i++) {
ct = m->realType(i);
if (ct) prev = ct;
}
for (int i=0;i<m->virtualCount();i++) {
ct = m->virtualType(i);
if (ct == _costType) break;
if (ct) prev = ct;
}
if (_data->mapping()->remove(ct)) {
// select previous cost type
selectedCostType(prev);
if (_costType2 == ct)
selectedCostType2(prev);
refresh();
}
}
else if (r == 97) {
int i = 1;
while(1) {
if (!TraceCostType::knownVirtualType(i18n("New%1").arg(i)))
break;
i++;
}
// add same new cost type to this mapping and to known types
QString shortName = i18n("New%1").arg(i);
QString longName = i18n("New Cost Type %1").arg(i);
TraceCostType::add(new TraceCostType(shortName, longName, "0"));
_data->mapping()->add(new TraceCostType(shortName, longName, "0"));
refresh();
}
}