当前位置: 首页>>代码示例>>C++>>正文


C++ QPopupMenu::removeItem方法代码示例

本文整理汇总了C++中QPopupMenu::removeItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QPopupMenu::removeItem方法的具体用法?C++ QPopupMenu::removeItem怎么用?C++ QPopupMenu::removeItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPopupMenu的用法示例。


在下文中一共展示了QPopupMenu::removeItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initLayoutList

void KxkbLabelController::initLayoutList(const QValueList< LayoutUnit > &layouts, const XkbRules &rules)
{
    //	KPopupMenu* menu = contextMenu();
    QPopupMenu *menu = contextMenu;
    //	int index = menu->indexOf(0);

    m_descriptionMap.clear();
    //    menu->clear();
    //    menu->insertTitle( kapp->miniIcon(), kapp->caption() );

    for(int ii = 0; ii < m_prevLayoutCount; ++ii)
    {
        menu->removeItem(START_MENU_ID + ii);
        kdDebug() << "remove item: " << START_MENU_ID + ii << endl;
    }
    /*	menu->removeItem(CONFIG_MENU_ID);
        menu->removeItem(HELP_MENU_ID);*/

    KIconEffect iconeffect;

    int cnt = 0;
    QValueList< LayoutUnit >::ConstIterator it;
    for(it = layouts.begin(); it != layouts.end(); ++it)
    {
        const QString layoutName = (*it).layout;
        const QString variantName = (*it).variant;

        const QPixmap &layoutPixmap = LayoutIcon::getInstance().findPixmap(layoutName, m_showFlag, (*it).displayName);
        const QPixmap pix = iconeffect.apply(layoutPixmap, KIcon::Small, KIcon::DefaultState);

        QString fullName = i18n((rules.layouts()[layoutName]));
        if(variantName.isEmpty() == false)
            fullName += " (" + variantName + ")";
        contextMenu->insertItem(pix, fullName, START_MENU_ID + cnt, m_menuStartIndex + cnt);
        m_descriptionMap.insert((*it).toPair(), fullName);

        cnt++;
    }

    m_prevLayoutCount = cnt;

    // if show config, if show help
    if(menu->indexOf(CONFIG_MENU_ID) == -1)
    {
        contextMenu->insertSeparator();
        contextMenu->insertItem(SmallIcon("configure"), i18n("Configure..."), CONFIG_MENU_ID);
        if(menu->indexOf(HELP_MENU_ID) == -1)
            contextMenu->insertItem(SmallIcon("help"), i18n("Help"), HELP_MENU_ID);
    }

    /*    if( index != -1 ) { //not first start
            menu->insertSeparator();
            KAction* quitAction = KStdAction::quit(this, SIGNAL(quitSelected()), actionCollection());
            if (quitAction)
                quitAction->plug(menu);
        }*/
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:57,代码来源:kxkbtraywindow.cpp

示例2: menuMessageHandler

bool PMenuData::menuMessageHandler(int fd, PukeMessage *pm)
{
    PukeMessage pmRet;
    int id = 0;
  switch(pm->iCommand){
  case PUKE_MENUDATA_INSERT_TEXT:
    {
      QPopupMenu *widget = (QPopupMenu *) child->widget();
      id = widget->insertItem(pm->cArg);
      if(pm->iArg > 0){
          widget->setAccel(pm->iArg, id);
      }

      pmRet.iCommand = PUKE_MENUDATA_INSERT_TEXT_ACK;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = id;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }
  case PUKE_MENUDATA_INSERT_PIXMAP:
    {
      QPopupMenu *widget = (QPopupMenu *) child->widget();
      id = widget->insertItem(QPixmap(pm->cArg));
      if(pm->iArg > 0){
          widget->setAccel(pm->iArg, id);
      }
    
      pmRet.iCommand = PUKE_MENUDATA_INSERT_PIXMAP_ACK;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = id;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }
  case PUKE_MENUDATA_REMOVE_ITEM:
    {
      QPopupMenu *widget = (QPopupMenu *) child->widget();
      widget->removeItem(pm->iArg);
    
      pmRet.iCommand = PUKE_MENUDATA_REMOVE_ITEM_ACK;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = pm->iArg;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }

  default:
    return FALSE;
  }
  return TRUE;
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:53,代码来源:pmenudta.cpp

示例3: initGUI


//.........这里部分代码省略.........
    // remove QString::null parameter -- ellis
    coll->readShortcutSettings( QString::null );
    m_accel = coll->accel();

    // menubar
    KMenuBar *mBar = menuBar();
    QPopupMenu *fileMenu = new QPopupMenu( mBar, "file" );
    open->plug( fileMenu );
    showInOther->plug( fileMenu );
    showInSame->plug( fileMenu );
    showFullscreen->plug( fileMenu );
    fileMenu->insertSeparator();
    slide->plug( fileMenu );
    print->plug( fileMenu );
    fileMenu->insertSeparator();
    quit->plug( fileMenu );

    QPopupMenu *editMenu = new QPopupMenu( mBar, "edit" );
    coll->action("mkdir")->plug( editMenu );
    coll->action("delete")->plug( editMenu );
    editMenu->insertSeparator();
    coll->action("properties")->plug( editMenu );


    // remove the Sorting submenu (and the separator below)
    // from the main contextmenu
    KActionMenu *sortingMenu = static_cast<KActionMenu*>( coll->action("sorting menu"));
    KActionMenu *mainActionMenu = static_cast<KActionMenu*>( coll->action("popupMenu"));
    QPopupMenu *mainPopup = mainActionMenu->popupMenu();
    int sortingIndex = mainPopup->indexOf( sortingMenu->itemId( 0 ) );
    int separatorId = mainPopup->idAt( sortingIndex + 1 );
    QMenuItem *separatorItem = mainPopup->findItem( separatorId );
    if ( separatorItem && separatorItem->isSeparator() )
        mainPopup->removeItem( separatorId );
    mainActionMenu->remove( sortingMenu );

    // add the sorting menu and a separator into the View menu
    KActionMenu *viewActionMenu = static_cast<KActionMenu*>( coll->action("view menu"));
    viewActionMenu->popupMenu()->insertSeparator( 0 );
    sortingMenu->plug( viewActionMenu->popupMenu(), 0 ); // on top of the menu


    QPopupMenu *settingsMenu = new QPopupMenu( mBar, "settings" );
    configure->plug( settingsMenu );

    mBar->insertItem( i18n("&File"), fileMenu );
    mBar->insertItem( i18n("&Edit"), editMenu );
    viewActionMenu->plug( mBar );
    mBar->insertItem( i18n("&Settings"), settingsMenu );

    // toolbar
    KToolBar *tBar = toolBar();
    tBar->setText( i18n( "Main Toolbar" ) );

    coll->action("up")->plug( tBar );
    coll->action("back")->plug( tBar );
    coll->action("forward")->plug( tBar );
    coll->action("home")->plug( tBar );
    coll->action("reload")->plug( tBar );

    tBar->insertSeparator();

    coll->action( "short view" )->plug( tBar );
    coll->action( "detailed view" )->plug( tBar );
    coll->action( "preview")->plug( tBar );
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:66,代码来源:kuickshow.cpp


注:本文中的QPopupMenu::removeItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。