本文整理汇总了C++中QPopupMenu::idAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QPopupMenu::idAt方法的具体用法?C++ QPopupMenu::idAt怎么用?C++ QPopupMenu::idAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPopupMenu
的用法示例。
在下文中一共展示了QPopupMenu::idAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SmallIconSet
QPopupMenu *KEdit::createPopupMenu(const QPoint &pos)
{
enum
{
IdUndo,
IdRedo,
IdSep1,
IdCut,
IdCopy,
IdPaste,
IdClear,
IdSep2,
IdSelectAll
};
QPopupMenu *menu = QMultiLineEdit::createPopupMenu(pos);
if(isReadOnly())
menu->changeItem(menu->idAt(0), SmallIconSet("editcopy"), menu->text(menu->idAt(0)));
else
{
int id = menu->idAt(0);
menu->changeItem(id - IdUndo, SmallIconSet("undo"), menu->text(id - IdUndo));
menu->changeItem(id - IdRedo, SmallIconSet("redo"), menu->text(id - IdRedo));
menu->changeItem(id - IdCut, SmallIconSet("editcut"), menu->text(id - IdCut));
menu->changeItem(id - IdCopy, SmallIconSet("editcopy"), menu->text(id - IdCopy));
menu->changeItem(id - IdPaste, SmallIconSet("editpaste"), menu->text(id - IdPaste));
menu->changeItem(id - IdClear, SmallIconSet("editclear"), menu->text(id - IdClear));
}
return menu;
}
示例2: initGUI
//.........这里部分代码省略.........
KAction *quit = KStdAction::quit( this, SLOT(slotQuit()), coll, "quit");
// 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 );