本文整理汇总了C++中QPopupMenu类的典型用法代码示例。如果您正苦于以下问题:C++ QPopupMenu类的具体用法?C++ QPopupMenu怎么用?C++ QPopupMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPopupMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QToolBar
void TextEdit::setupEditActions()
{
QToolBar *tb = new QToolBar( this );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "&Edit" ), menu );
QAction *a;
a = new QAction( tr( "Undo" ), QPixmap( "textdrawing/undo.png" ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( tr( "Redo" ), QPixmap( "textdrawing/redo.png" ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( tr( "Cut" ), QPixmap( "textdrawing/editcut.png" ), tr( "&Cut" ), CTRL + Key_X, this, "editCut" );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( tr( "Copy" ), QPixmap( "textdrawing/editcopy.png" ), tr( "C&opy" ), CTRL + Key_C, this, "editCopy" );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( tr( "Paste" ), QPixmap( "textdrawing/editpaste.png" ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( tb );
a->addTo( menu );
}
示例2: selectTab
void UserTabBar::mousePressEvent(QMouseEvent *e)
{
if (e->button() == RightButton){
QTab *t = selectTab(e->pos());
if (t == NULL) return;
UserTab *tab = static_cast<UserTab*>(t);
EventMenuProcess eMenu(MenuContact, (void*)tab->wnd()->id());
eMenu.process();
QPopupMenu *menu = eMenu.menu();
if (menu)
menu->popup(e->globalPos());
return;
}
if (e->button() == MidButton){
//Close tab on middle button pressed
QTab *t = selectTab(e->pos());
if (t == NULL) return;
UserTab *tab = static_cast<UserTab*>(t);
Command cmd;
cmd->id = CmdClose;
cmd->param = (void*)tab->wnd()->id();
EventCommandExec(cmd).process();
}
QTabBar::mousePressEvent(e);
}
示例3: QToolBar
void TextEdit::setupEditActions()
{
QToolBar *tb = new QToolBar( this );
tb->setLabel( "Edit Actions" );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "&Edit" ), menu );
QAction *a;
a = new QAction( QPixmap::fromMimeSource( "editundo.xpm" ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editredo.xpm" ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( QPixmap::fromMimeSource( "editcopy.xpm" ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editcut.xpm" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editpaste.xpm" ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( tb );
a->addTo( menu );
}
示例4: if
void K3bIsoImageWritingDialog::slotContextMenu( KListView*, QListViewItem*, const QPoint& pos )
{
if( !d->haveMd5Sum )
return;
QPopupMenu popup;
int copyItem = popup.insertItem( i18n("Copy checksum to clipboard") );
int compareItem = popup.insertItem( i18n("Compare checksum...") );
int r = popup.exec( pos );
if( r == compareItem ) {
bool ok;
QString md5sumToCompare = KInputDialog::getText( i18n("MD5 Sum Check"),
i18n("Please insert the MD5 Sum to compare:"),
QString::null,
&ok,
this );
if( ok ) {
if( md5sumToCompare.lower().utf8() == m_md5Job->hexDigest().lower() )
KMessageBox::information( this, i18n("The MD5 Sum of %1 equals the specified.").arg(imagePath()),
i18n("MD5 Sums Equal") );
else
KMessageBox::sorry( this, i18n("The MD5 Sum of %1 differs from the specified.").arg(imagePath()),
i18n("MD5 Sums Differ") );
}
}
else if( r == copyItem ) {
QApplication::clipboard()->setText( m_md5Job->hexDigest().lower(), QClipboard::Clipboard );
}
}
示例5: context
void CoverageView::context(QListViewItem* i, const QPoint & p, int c)
{
QPopupMenu popup;
TraceFunction* f = 0;
if (i) {
f = _showCallers ?
((CallerCoverageItem*)i)->function() :
((CalleeCoverageItem*)i)->function();
}
if (f) {
QString name = f->name();
if ((int)name.length()>Configuration::maxSymbolLength())
name = name.left(Configuration::maxSymbolLength()) + "...";
popup.insertItem(i18n("Go to '%1'").arg(name), 93);
popup.insertSeparator();
}
if ((c == 0) || (!_showCallers && c == 1)) {
addCostMenu(&popup, false);
popup.insertSeparator();
}
addGoMenu(&popup);
int r = popup.exec(p);
if (r == 93) activated(f);
}
示例6: main
int main( int argc, char **argv )
{
QApplication app( argc, argv );
QMainWindow mw;
app.setMainWidget( &mw );
QPopupMenu menu2;
menu2.insertItem( "Test 2" );
TrayIcon tray2( QPixmap( (const char**)minimize_xpm ), "Minimize MainWindow", &menu2 );
QObject::connect(&tray2,SIGNAL(clicked(const QPoint&)),&mw,SLOT(showMinimized()));
QPopupMenu menu;
menu.insertItem( "Test 1" );
menu.insertSeparator();
menu.insertItem( "&Quit", &app, SLOT(quit()) );
TrayIcon tray( QPixmap( (const char**)normalize_xpm ), "Show MainWindow", &menu );
QObject::connect(&tray,SIGNAL(clicked(const QPoint&)),&mw,SLOT(showNormal()));
TrayIcon tray3( QPixmap( (const char**)maximize_xpm ), "Maximize MainWindow" );
QObject::connect(&tray3,SIGNAL(clicked(const QPoint&)),&mw,SLOT(showMaximized()));
mw.show();
tray.show();
tray2.show();
tray3.show();
return app.exec();
}
示例7: tree
void KonqSidebarBookmarkModule::showPopupMenu()
{
KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() );
if (!bi)
return;
bool tabSupported = tree()->tabSupport();
QPopupMenu *menu = new QPopupMenu;
if (bi->bookmark().isGroup()) {
if (tabSupported) {
m_collection->action("folder_open_tabs")->plug(menu);
menu->insertSeparator();
}
m_collection->action("create_folder")->plug(menu);
m_collection->action("delete_folder")->plug(menu);
} else {
m_collection->action("open_window")->plug(menu);
if (tabSupported)
m_collection->action("open_tab")->plug(menu);
m_collection->action("copy_location")->plug(menu);
menu->insertSeparator();
m_collection->action("create_folder")->plug(menu);
m_collection->action("delete_bookmark")->plug(menu);
}
menu->insertSeparator();
m_collection->action("item_properties")->plug(menu);
menu->exec( QCursor::pos() );
delete menu;
}
示例8: checkInsertIndex
void KTagComboBox::insertItem(const QString &text, const QString &tag, const QString &submenu, int index )
{
QPopupMenu *pi = checkInsertIndex(popup, tags, submenu);
checkInsertPos(pi, text, index);
pi->insertItem(text, count(), index);
tags.append(tag);
}
示例9: QPopupMenu
void VCFrame::invokeMenu(QPoint point)
{
QPopupMenu* menu = VCWidget::createMenu();
// Add menu
QPopupMenu* addMenu = new QPopupMenu(menu);
addMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/button.png")),
"&Button", KVCMenuAddButton);
addMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/slider.png")),
"&Slider", KVCMenuAddSlider);
addMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/frame.png")),
"&Frame", KVCMenuAddFrame);
addMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/xypad.png")),
"&XY-Pad", KVCMenuAddXYPad);
addMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/label.png")),
"L&abel", KVCMenuAddLabel);
menu->insertSeparator();
menu->insertItem("Add", addMenu);
connect(addMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
menu->exec(point);
delete menu;
}
示例10: QPopupMenu
void ClassMainWindow::slotRightClick( QListViewItem *, const QPoint &pos, int )
{
QPopupMenu *menu = new QPopupMenu( this );
menu->insertItem( i18n( "&Add" ), this, SLOT(slotAdd()) );
menu->insertItem( i18n( "&Remove" ), this, SLOT(slotRemove()) );
menu->popup( pos );
}
示例11: QString
//
// Invoke a menu at given point
//
void VCDockSlider::invokeMenu(QPoint point)
{
if (m_static)
{
QString dir;
_app->settings()->get(KEY_SYSTEM_DIR, dir);
dir += QString("/") + PIXMAPPATH;
QPopupMenu menu;
menu.insertItem(QPixmap(dir + "/settings.xpm"),
QString("&Properties..."), KVCMenuEditProperties);
if (menu.exec(point) == KVCMenuEditProperties)
{
bool ok = false;
QString current;
current.sprintf("%d-%d", m_busLowLimit, m_busHighLimit);
QString text =
QInputDialog::getText(KApplicationNameShort,
"Slider value range (e.g. 0-10) in seconds:",
QLineEdit::Normal, current, &ok, this);
if (ok && !text.isEmpty())
{
int dash = text.find('-');
QString min = text.left(dash);
QString max = text.mid(dash + 1);
if (min.toInt() >= max.toInt())
{
QMessageBox::warning(this, KApplicationNameShort,
"Minimum value cannot be bigger than or equal to the maximum value");
}
else
{
setBusRange(min.toInt(), max.toInt());
setMode(Speed);
if (m_busID == KBusIDDefaultFade)
{
_app->settings()->set(KEY_DEFAULT_FADE_MIN, min.toInt());
_app->settings()->set(KEY_DEFAULT_FADE_MAX, max.toInt());
}
else
{
_app->settings()->set(KEY_DEFAULT_HOLD_MIN, min.toInt());
_app->settings()->set(KEY_DEFAULT_HOLD_MAX, max.toInt());
}
}
}
}
}
else
{
_app->virtualConsole()->editMenu()->exec(point);
}
}
示例12: invokeDMXValueMenu
/**
* Set a value to a min/max/reverse column using a context menu
*/
void VCXYPadProperties::slotContextMenuRequested(QListViewItem* item,
const QPoint &point,
int column)
{
int result;
QString s;
if (column == KColumnLo)
{
result = invokeDMXValueMenu(point);
if (result <= KChannelValueMax &&
result >= KChannelValueMin)
{
s.sprintf("%.3d", result);
item->setText(KColumnLo, s);
slotSelectionXChanged(m_listX->currentItem());
slotSelectionYChanged(m_listY->currentItem());
}
}
else if (column == KColumnHi)
{
result = invokeDMXValueMenu(point);
if (result <= KChannelValueMax &&
result >= KChannelValueMin)
{
s.sprintf("%.3d", result);
item->setText(KColumnHi, s);
slotSelectionXChanged(m_listX->currentItem());
slotSelectionYChanged(m_listY->currentItem());
}
}
else if (column == KColumnReverse)
{
QPopupMenu* menu = new QPopupMenu();
menu->insertItem("Reverse", KNoID);
menu->insertSeparator();
menu->insertItem(Settings::trueValue(), KComboItemReverse);
menu->insertItem(Settings::falseValue(), KComboItemNormal);
result = menu->exec(point);
if (result == KComboItemNormal)
{
item->setText(KColumnReverse, Settings::falseValue());
}
else if (result == KComboItemReverse)
{
item->setText(KColumnReverse, Settings::trueValue());
}
slotSelectionXChanged(m_listX->currentItem());
slotSelectionYChanged(m_listY->currentItem());
delete menu;
}
}
示例13: qDebug
void GadWorkspace::genMenu()
{
qDebug("GadWorkspace::genMenu\n");
if (!menubar_) {
QtGui *mainmenu = (QtGui *) (*(_qtguiappl->classDict()))["mainmenu"];
if (mainmenu) {
QWidget *w = mainmenu->widget();
if (w && w->inherits("QMenuBar"))
menubar_ = (QMenuBar *) w;
}
}
const ClassDict & classDict = *classDict_;
int size = 0;
QStringList classList;
QDictIterator < ModuleDict > cit(classDict);
for (; cit.current(); ++cit) {
size += cit.current()->count();
classList += cit.currentKey();
}
if (classNameMenu_)
delete classNameMenu_;
classNameMenu_ = new ClassNameMenu[size];
if (popup_)
delete popup_;
popup_ = new QPopupMenu(0);
classList.sort();
QStringList::Iterator clit;
int item = 0;
for (clit = classList.begin(); clit != classList.end(); ++clit) {
qDebug("Class %s\n", (const char *) *clit);
QPopupMenu *popup = new QPopupMenu();
popup_->insertItem(*clit, popup);
connect(popup, SIGNAL(activated(int)), this, SLOT(newObjectSlot(int)));
ModuleDict *moduleDict = classDict[*clit];
QDictIterator < GadModule > mit(*moduleDict);
QStringList moduleList;
qDebug("test\n");
for (; mit.current(); ++mit)
moduleList += mit.currentKey();
moduleList.sort();
QStringList::Iterator mlit;
qDebug("test\n");
for (mlit = moduleList.begin(); mlit != moduleList.end(); ++mlit) {
qDebug("item=%d\n", item);
classNameMenu_[item].className = *clit;
classNameMenu_[item].name = *mlit;
popup->insertItem(*mlit, item++);
// popup->insertItem(*mlit,this,SLOT(genNewObject(int)),0,item);
qDebug("test\n");
}
}
if (menubar_)
popupId_ = menubar_->insertItem("&Glyphs", popup_);
qDebug(" connecting with mainMenu\n");
// _qtguiappl->insertClass("classmenu",popup_);
}
示例14: showPopup
void MainWindow::showPopup()
{
popupTimer->stop();
if (!_currentItem)
return;
QPopupMenu *pop = _currentItem->popupMenu();
if (pop) pop->popup( QCursor::pos() );
}
示例15: tr
QPopupMenu *Editor::createPopupMenu( const QPoint &p )
{
QPopupMenu *menu = QTextEdit::createPopupMenu( p );
menu->insertSeparator();
menu->insertItem( tr( "C&omment Code\tAlt+C" ), this, SLOT( commentSelection() ) );
menu->insertItem( tr( "Unco&mment Code\tAlt+U" ), this, SLOT( uncommentSelection() ) );
return menu;
}