本文整理汇总了C++中QMenu::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::exec方法的具体用法?C++ QMenu::exec怎么用?C++ QMenu::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contextMenuRequested
void HistoryManager::contextMenuRequested(const QPoint &position)
{
if (!ui->historyTree->itemAt(position)) {
return;
}
QUrl link = QUrl::fromEncoded(ui->historyTree->itemAt(position)->text(1).toUtf8());
if (link.isEmpty()) {
return;
}
QMenu menu;
menu.addAction(tr("Open link in actual tab"), getQupZilla(), SLOT(loadActionUrl()))->setData(link);
menu.addAction(tr("Open link in new tab"), this, SLOT(loadInNewTab()))->setData(link);
menu.addSeparator();
menu.addAction(tr("Copy address"), this, SLOT(copyUrl()))->setData(link);
//Prevent choosing first option with double rightclick
QPoint pos = QCursor::pos();
QPoint p(pos.x(), pos.y() + 1);
menu.exec(p);
}
示例2: rightClickMenu
void TicketListV::rightClickMenu(const QPoint& pos){
QPoint point = this->ui->tableView->mapToGlobal(pos);
QMenu rightClickMenu;
QAction* editTicketAction = rightClickMenu.addAction("Edit Ticket");
QAction* editCustomerAction = rightClickMenu.addAction("Edit Customer");
QAction* ticketHistoryAction = rightClickMenu.addAction("Ticket History");
QAction* select = rightClickMenu.exec(point);
if(select == editTicketAction){
editTicket();
}
else if (select == editCustomerAction){
editCus();
}
else if (select == ticketHistoryAction){
QItemSelectionModel *selectModel = ui->tableView->selectionModel();
QModelIndex row = selectModel->currentIndex();
QString stringID = ui->tableView->model()->data(ui->tableView->model()->index(row.row(), 0)).toString();
HistoryView *historyView = new HistoryView(0, stringID);
historyView->exec();
}
}
示例3: cast
QModelIndex cast( NifModel * nif, const QModelIndex & index )
{
QModelIndex idx = index;
if ( nif->itemType( index ).toLower() != "texcoord" )
{
idx = nif->getIndex( nif->getBlock( index ), "UV Sets" );
}
QMenu menu;
static const char * const flipCmds[3] = { "S = 1.0 - S", "T = 1.0 - T", "S <=> T" };
for ( int c = 0; c < 3; c++ )
menu.addAction( flipCmds[c] );
QAction * act = menu.exec( QCursor::pos() );
if ( act ) {
for ( int c = 0; c < 3; c++ )
if ( act->text() == flipCmds[c] )
flip( nif, idx, c );
}
return index;
}
示例4: contextMenuEvent
/**
* Allow changing terrain properties through a context menu.
*/
void TerrainView::contextMenuEvent(QContextMenuEvent *event)
{
Terrain *terrain = terrainAt(indexAt(event->pos()));
if (!terrain)
return;
if (!mTilesetDocument)
return;
QMenu menu;
QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));
QAction *terrainProperties = menu.addAction(propIcon,
tr("Terrain &Properties..."));
Utils::setThemeIcon(terrainProperties, "document-properties");
connect(terrainProperties, &QAction::triggered,
this, &TerrainView::editTerrainProperties);
menu.exec(event->globalPos());
}
示例5: contextMenuEvent
void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
{
if(isSelected())
{
QGraphicsScene* graphicsScene = scene();
if(StreamEditorScene* streamScene = qobject_cast<StreamEditorScene*>(graphicsScene))
{
QMenu menu;
QList<QAction*> actions = streamScene->selectionModel()->createThreadActions(&menu);
if(actions.count())
{
foreach(QAction* action, actions)
menu.addAction(action);
menu.exec(event->screenPos());
}
}
}
}
示例6: contextMenuEvent
void FloatEdit::contextMenuEvent( QContextMenuEvent * event )
{
QMenu * mnuContext = new QMenu( this );
mnuContext->setMouseTracking( true );
QMenu * mnuStd = createStandardContextMenu();
if( validator->canMin() )
mnuContext->addAction( actMin );
if( validator->canMax() )
mnuContext->addAction( actMax );
if( validator->canMin() || validator->canMax() )
mnuContext->addSeparator();
mnuContext->addActions( mnuStd->actions() );
mnuContext->exec( event->globalPos() );
delete mnuStd;
delete mnuContext;
}
示例7: contextMenuEvent
void TemplatesView::contextMenuEvent(QContextMenuEvent *event)
{
const QModelIndex index = indexAt(event->pos());
if (!index.isValid())
return;
QMenu menu;
Utils::addFileManagerActions(menu, mModel->filePath(index));
if (ObjectTemplate *objectTemplate = mModel->toObjectTemplate(index)) {
menu.addSeparator();
QAction *action = menu.addAction(tr("Select All Instances"));
connect(action, &QAction::triggered, [objectTemplate] {
MapDocumentActionHandler *handler = MapDocumentActionHandler::instance();
handler->selectAllInstances(objectTemplate);
});
}
menu.exec(event->globalPos());
}
示例8: skp_on_activated
void SkpMainWindow::skp_on_activated(QSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
case QSystemTrayIcon::Context:
{
QMenu menu;
menu.addAction(tr("show"), this, SLOT(skp_on_Show()));
menu.addAction(tr("hide"), this, SLOT(skp_on_min()));
menu.addAction(tr("quit"), this, SLOT(skp_on_close()));
QPoint globalPoint = QCursor::pos();
menu.exec(globalPoint);
}
break;
case QSystemTrayIcon::DoubleClick:
case QSystemTrayIcon::Trigger:
default:
skp_on_Show();
break;
}
}
示例9: contextMenuEvent
void WangSetView::contextMenuEvent(QContextMenuEvent *event)
{
WangSet *wangSet = wangSetAt(indexAt(event->pos()));
if (!wangSet)
return;
if (!mTilesetDocument)
return;
QMenu menu;
QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));
QAction *wangSetProperties = menu.addAction(propIcon,
tr("Wang Set &Properties..."));
Utils::setThemeIcon(wangSetProperties, "document-properties");
connect(wangSetProperties, SIGNAL(triggered()),
SLOT(editWangSetProperties()));
menu.exec(event->globalPos());
}
示例10: contextMenuEvent
void CustomLabel::contextMenuEvent(QContextMenuEvent* e) {
if (editable_) {
QMenu* men = new QMenu(this);
men->addAction("Rename");
men->addAction("Set Default");
QAction* ac = men->exec(e->globalPos());
if(ac != 0) {
if(ac->iconText().compare("Rename") == 0) {
edit_->setText(text());
edit_->setFocus();
edit_->setCursorPosition(edit_->text().length());
edit_->resize(size());
edit_->show();
} else {
propertyWidget_->getProperty()->reset();
if(dynamic_cast<TransFuncProperty*>(propertyWidget_->getProperty()))
propertyWidget_->getProperty()->invalidate();
}
}
}
}
示例11: colorItemMenu
void DisplayPrefsDialog::colorItemMenu( const QPoint & pos )
{
QTreeWidgetItem * c = mColorTree->currentItem();
int cc = mColorTree->currentColumn();
if( c && cc > 0 && c->type() == ColorItemType ) {
ColorItem * ci = static_cast<ColorItem*>(c);
QMenu * m = new QMenu(this);
QAction * c = m->addAction( "Clear" );
QAction * r = m->exec( mColorTree->mapToGlobal(pos) );
if( r==c ) {
if( cc == 1 )
ci->fg = QColor();
else if( cc == 2 )
ci->bg = QColor();
ci->update();
mChanges = true;
ApplyButton->setEnabled(true);
}
delete m;
}
}
示例12: contextMenuEvent
/**
\return
**/
void BlTreeWidget::contextMenuEvent ( QContextMenuEvent * )
{
BL_FUNC_DEBUG
int column = currentColumn();
if ( column < 0 ) return;
QMenu *menu = new QMenu ( this );
/// Lanzamos el evento para que pueda ser capturado por terceros.
emit pintaMenu ( menu );
/// Lanzamos la propagación del menú a través de las clases derivadas.
createMenu ( menu );
QAction *adjustColumnSize = menu->addAction ( _ ( "Ajustar columa" ) );
QAction *adjustAllColumnsSize = menu->addAction ( _ ( "Ajustar columnas" ) );
QAction *menuOption = menu->exec ( QCursor::pos() );
/// Si no hay ninguna opción pulsada se sale sin hacer nada.
if ( !menuOption ) return;
if ( menuOption == adjustAllColumnsSize ) {
for (int i = 0; i < columnCount(); i++) {
resizeColumnToContents (i);
} // end for
} else if ( menuOption == adjustColumnSize ) {
resizeColumnToContents ( column );
} // end if
emit trataMenu ( menuOption );
/// Activamos las herederas.
execMenuAction ( menuOption );
delete menu;
}
示例13: onFileClicked
void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) {
if(type == ActivatedClick) {
if(fileLauncher_) {
GList* files = g_list_append(nullptr, fileInfo);
fileLauncher_->launchFiles(nullptr, files);
g_list_free(files);
}
}
else if(type == ContextMenuClick) {
FmPath* folderPath = nullptr;
FmFileInfoList* files = selectedFiles();
if (files) {
FmFileInfo* first = fm_file_info_list_peek_head(files);
if (fm_file_info_list_get_length(files) == 1 && fm_file_info_is_dir(first))
folderPath = fm_file_info_get_path(first);
}
if (!folderPath)
folderPath = path();
QMenu* menu = nullptr;
if(fileInfo) {
// show context menu
if (FmFileInfoList* files = selectedFiles()) {
Fm::FileMenu* fileMenu = new Fm::FileMenu(files, fileInfo, folderPath);
fileMenu->setFileLauncher(fileLauncher_);
prepareFileMenu(fileMenu);
fm_file_info_list_unref(files);
menu = fileMenu;
}
}
else {
Fm::FolderMenu* folderMenu = new Fm::FolderMenu(this);
prepareFolderMenu(folderMenu);
menu = folderMenu;
}
if (menu) {
menu->exec(QCursor::pos());
delete menu;
}
}
}
示例14: eventFilter
bool SelectGroupParticipantsWindow::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::ContextMenu) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);
QPoint p = mouseEvent->globalPos();
QModelIndex index = ui->listView->indexAt(
ui->listView->viewport()->mapFromGlobal(p));
if (index.isValid())
{
QString jid = index.data(Qt::UserRole + 1).toString();
QMenu *menu = new QMenu(this);
QAction *removeContact = new QAction("Remove Contact",this);
menu->addAction(removeContact);
QAction *action = menu->exec(p);
if (action == removeContact)
{
QMessageBox msg(this);
msg.setText("Are you sure you want to remove this contact from this group?");
msg.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
if (msg.exec() == QMessageBox::Yes)
{
model->removeRow(index.row());
participants.remove(jid);
ui->listView->clearSelection();
}
return true;
}
}
}
return QMainWindow::eventFilter(obj, event);
}
示例15: contextMenuRequested
void FooTabBar::contextMenuRequested (const QPoint &position)
{
/*
Renane Playlist
Remove Playlist
Add New Playlist
---
Move Left
Move Right
---
Save All Playlists...
Save Playlist...
Load Playlist...
---
"<playlist-name>" Contents > -- odpuścić na razie
*/
QMenu menu;
menu.addAction(tr("New Playlist..."), this, SIGNAL(newTab()), QKeySequence::New);
int index = tabAt(position);
if (-1 != index)
{
menu.addAction(tr("&Duplicate Playlist"), this, SLOT(cloneTab()))->setData(index);
menu.addSeparator();
menu.addAction(tr("&Close Playlist"), this, SLOT(closeTab()), QKeySequence::Close)->setData(index);
menu.addSeparator();
menu.addAction (tr ("Close &Other Playlists"), this, SLOT (closeOtherTabs()))->setData(index);
menu.addSeparator();
menu.addAction (tr ("&Rename Playlist"), this, SLOT(renameTab()))->setData(index);
}
menu.exec (QCursor::pos());
}