本文整理汇总了C++中QAction::setMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setMenu方法的具体用法?C++ QAction::setMenu怎么用?C++ QAction::setMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeClass
void ViewManager::initializeClass(ExtensionManager* ext)
{
static bool initialized = false;
if(!initialized){
mainWindow = MainWindow::instance();
MenuManager& mm = ext->menuManager();
QWidget* viewMenu = mm.setPath("/View").current();
QAction* showViewAction = mm.findItem("Show View");
showViewMenu = new Menu(viewMenu);
showViewMenu->sigAboutToShow().connect(boost::bind(onViewMenuAboutToShow, showViewMenu));
showViewAction->setMenu(showViewMenu);
QAction* createViewAction = mm.setCurrent(viewMenu).findItem("Create View");
createViewMenu = new Menu(viewMenu);
createViewMenu->sigAboutToShow().connect(boost::bind(onViewMenuAboutToShow, createViewMenu));
createViewAction->setMenu(createViewMenu);
QAction* deleteViewAction = mm.setCurrent(viewMenu).findItem("Delete View");
deleteViewMenu = new Menu(viewMenu);
deleteViewMenu->sigAboutToShow().connect(boost::bind(onViewMenuAboutToShow, deleteViewMenu));
deleteViewAction->setMenu(deleteViewMenu);
initialized = true;
}
}
示例2: tmp
KviMircTextColorSelector::KviMircTextColorSelector(QWidget * par,const QString &txt,unsigned int * uFore,unsigned int * uBack,bool bEnabled)
: KviTalHBox(par), KviSelectorInterface()
{
m_pLabel = new QLabel(txt,this);
m_pButton = new QPushButton(__tr2qs("Sample Text"),this);
// m_pButton->setMinimumWidth(150);
connect(m_pButton,SIGNAL(clicked()),this,SLOT(buttonClicked()));
setSpacing(4);
setStretchFactor(m_pLabel,1);
m_pUFore = uFore;
m_pUBack = uBack;
m_uBack = *uBack;
m_uFore = *uFore;
setButtonPalette();
setEnabled(bEnabled);
m_pContextPopup = new QMenu(this);
QAction *pAction = 0;
m_pForePopup = new QMenu(this);
connect(m_pForePopup,SIGNAL(triggered(QAction*)),this,SLOT(foreSelected(QAction*)));
int iColor;
for(iColor=0;iColor<KVI_MIRCCOLOR_MAX_FOREGROUND;iColor++)
{
QPixmap tmp(120,16);
tmp.fill(KVI_OPTION_MIRCCOLOR(iColor));
pAction = m_pForePopup->addAction(tmp,QString("x"));
pAction->setData(iColor);
}
pAction = m_pContextPopup->addAction(__tr2qs("Foreground"));
pAction->setMenu(m_pForePopup);
m_pBackPopup = new QMenu(this);
connect(m_pBackPopup,SIGNAL(triggered(QAction*)),this,SLOT(backSelected(QAction*)));
pAction = m_pBackPopup->addAction(__tr2qs("Transparent"));
pAction->setData(KviControlCodes::Transparent);
for(iColor=0;iColor<KVI_MIRCCOLOR_MAX_BACKGROUND;iColor++)
{
QPixmap tmp(120,16);
tmp.fill(KVI_OPTION_MIRCCOLOR(iColor));
pAction = m_pBackPopup->addAction(tmp,QString("x"));
pAction->setData(iColor);
}
pAction = m_pContextPopup->addAction(__tr2qs("Background"));
pAction->setMenu(m_pBackPopup);
}
示例3: init
void QDiagramWidget::init(const GPX_wrapper *gpxmw)
{
const GPX_wrapper::TrackPointProperty choices[] = {
GPX_wrapper::none,
GPX_wrapper::distance,
GPX_wrapper::leglength,
GPX_wrapper::speed,
GPX_wrapper::altitude,
GPX_wrapper::latitude,
GPX_wrapper::longitude,
GPX_wrapper::heading,
GPX_wrapper::sat,
GPX_wrapper::magvar,
GPX_wrapper::hdop,
GPX_wrapper::vdop,
GPX_wrapper::pdop,
GPX_wrapper::ageofdgpsdata,
GPX_wrapper::dgpsid,
GPX_wrapper::geoidheight,
GPX_wrapper::heartrate
};
this->gpxmw = gpxmw;
curveMain = GPX_wrapper::altitude;
curveSecondary = GPX_wrapper::distance;
QAction *actCurveMain = new QAction("Main curve", this);
QAction *actCurveSecondary = new QAction("Secondary curve", this);
QMenu *submenuCurveMain = new QMenu;
QMenu *submenuCurveSecondary = new QMenu;
actCurveMain->setMenu(submenuCurveMain);
actCurveSecondary->setMenu(submenuCurveSecondary);
addAction(actCurveMain);
addAction(actCurveSecondary);
for (size_t i = 0; i < sizeof(choices)/sizeof(GPX_wrapper::TrackPointProperty); ++i)
{
QAction *actCurveMain = new QAction(gpxmw->getTrackPointPropertyLabel(choices[i]), this);
actCurveMain->setData(choices[i]);
connect(actCurveMain, SIGNAL(triggered()), this, SLOT(on_actionCurveMain_triggered()));
submenuCurveMain->addAction(actCurveMain);
QAction *actCurveSecondary = new QAction(gpxmw->getTrackPointPropertyLabel(choices[i]), this);
actCurveSecondary->setData(choices[i]);
connect(actCurveSecondary, SIGNAL(triggered()), this, SLOT(on_actionCurveSecondary_triggered()));
submenuCurveSecondary->addAction(actCurveSecondary);
}
build();
}
示例4: updateBookmarks
void MainWindow::updateBookmarks(int folder)
{
if (m_ui->menuBookmarks->actions().count() == 3)
{
return;
}
for (int i = (m_ui->menuBookmarks->actions().count() - 1); i > 2; --i)
{
QAction *action = m_ui->menuBookmarks->actions().at(i);
if (folder == 0)
{
action->deleteLater();
m_ui->menuBookmarks->removeAction(action);
}
else if (m_ui->menuBookmarks->actions().at(i)->menu())
{
action->menu()->deleteLater();
action->setMenu(new QMenu());
connect(action->menu(), SIGNAL(aboutToShow()), this, SLOT(menuBookmarksAboutToShow()));
}
}
}
示例5: setMenu
int Action::setMenu(lua_State * L) // ( QMenu * menu )
{
QAction* obj = QtObject<QAction>::check( L, 1);
QMenu* rhs = QtObject<QMenu>::check( L, 2);
obj->setMenu( rhs );
return 0;
}
示例6: setMenu
void DayPage::setMenu(QMenu *menu)
{
// Add softkey for symbian
QAction* optionsSoftKey = new QAction("Options", this);
optionsSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
optionsSoftKey->setMenu(menu);
addAction(optionsSoftKey);
}
示例7: setServiceMenu
void Configuration::setServiceMenu()
{
KMenu *menu = qobject_cast<KMenu*>(sender());
if (menu->actions().count() > 1)
{
return;
}
KServiceGroup::Ptr rootGroup = KServiceGroup::group(menu->actions()[0]->data().toString());
if (!rootGroup || !rootGroup->isValid() || rootGroup->noDisplay())
{
return;
}
KServiceGroup::List list = rootGroup->entries(true, true, true, true);
QAction *action = menu->addAction(KIcon("list-add"), i18n("Add This Menu"));
action->setData(rootGroup->relPath());
menu->addSeparator();
for (int i = 0; i < list.count(); ++i)
{
if (list.at(i)->isType(KST_KService))
{
const KService::Ptr service = KService::Ptr::staticCast(list.at(i));
action = menu->addAction(KIcon(service->icon()), service->name());
action->setEnabled(false);
}
else if (list.at(i)->isType(KST_KServiceGroup))
{
const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(list.at(i));
if (group->noDisplay() || group->childCount() == 0)
{
continue;
}
KMenu *subMenu = new KMenu(menu);
QAction *action = subMenu->addAction(QString());
action->setData(group->relPath());
action->setVisible(false);
action = menu->addAction(KIcon(group->icon()), group->caption());
action->setMenu(subMenu);
connect(subMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu()));
}
else if (list.at(i)->isType(KST_KServiceSeparator))
{
menu->addSeparator();
}
}
}
示例8: foreach
QList<QAction*> ExtractFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget)
{
QList<QAction*> actions;
const QIcon icon = QIcon::fromTheme(QStringLiteral("archive-extract"));
bool readOnlyParentDir = false;
QList<QUrl> supportedUrls;
// Filter URLs by supported mimetypes.
foreach (const QUrl &url, fileItemInfos.urlList()) {
const QMimeType mimeType = determineMimeType(url.path());
if (m_pluginManager->preferredPluginsFor(mimeType).isEmpty()) {
continue;
}
supportedUrls << url;
// Check whether we can write in the parent directory of the file.
const QString directory = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile();
if (!QFileInfo(directory).isWritable()) {
readOnlyParentDir = true;
}
}
if (supportedUrls.isEmpty()) {
return {};
}
QMenu *extractMenu = new QMenu(parentWidget);
extractMenu->addAction(createAction(icon,
i18nc("@action:inmenu Part of Extract submenu in Dolphin context menu", "Extract archive here"),
parentWidget,
supportedUrls,
QStringLiteral("ark --batch --autodestination %F")));
extractMenu->addAction(createAction(icon,
i18nc("@action:inmenu Part of Extract submenu in Dolphin context menu", "Extract archive to..."),
parentWidget,
supportedUrls,
QStringLiteral("ark --batch --autodestination --dialog %F")));
extractMenu->addAction(createAction(icon,
i18nc("@action:inmenu Part of Extract submenu in Dolphin context menu", "Extract archive here, autodetect subfolder"),
parentWidget,
supportedUrls,
QStringLiteral("ark --batch --autodestination --autosubfolder %F")));
QAction *extractMenuAction = new QAction(i18nc("@action:inmenu Extract submenu in Dolphin context menu", "Extract"), parentWidget);
extractMenuAction->setMenu(extractMenu);
extractMenuAction->setIcon(icon);
// #189177: disable extract menu in read-only folders.
if (readOnlyParentDir) {
extractMenuAction->setEnabled(false);
}
actions << extractMenuAction;
return actions;
}
示例9: QAction
QAction *MenuBarManager::insertMenu( int index , const QString & name , QMenu *menu )
{
QAction *action = new QAction( name , this );
action->setMenu( menu );
this->insertAction( index , action );
return action;
}
示例10: QDialog
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
clientProgressBar = new QProgressBar;
clientStatusLabel = new QLabel(tr("Client ready"));
serverProgressBar = new QProgressBar;
serverStatusLabel = new QLabel(tr("Server ready"));
#ifdef Q_OS_SYMBIAN
QMenu *menu = new QMenu(this);
QAction *optionsAction = new QAction(tr("Options"), this);
optionsAction->setSoftKeyRole(QAction::PositiveSoftKey);
optionsAction->setMenu(menu);
addAction(optionsAction);
startAction = menu->addAction(tr("Start"), this, SLOT(start()));
quitAction = new QAction(tr("Exit"), this);
quitAction->setSoftKeyRole(QAction::NegativeSoftKey);
addAction(quitAction);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
#else
startButton = new QPushButton(tr("&Start"));
quitButton = new QPushButton(tr("&Quit"));
buttonBox = new QDialogButtonBox;
buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
#endif
connect(&tcpServer, SIGNAL(newConnection()),
this, SLOT(acceptConnection()));
connect(&tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
connect(&tcpClient, SIGNAL(bytesWritten(qint64)),
this, SLOT(updateClientProgress(qint64)));
connect(&tcpClient, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(displayError(QAbstractSocket::SocketError)));
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(clientProgressBar);
mainLayout->addWidget(clientStatusLabel);
mainLayout->addWidget(serverProgressBar);
mainLayout->addWidget(serverStatusLabel);
mainLayout->addStretch(1);
mainLayout->addSpacing(10);
#ifndef Q_OS_SYMBIAN
mainLayout->addWidget(buttonBox);
#endif
setLayout(mainLayout);
setWindowTitle(tr("Loopback"));
}
示例11: createPromotionActions
PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDesignerFormWindowInterface *formWindow)
{
// clear out old
if (!m_promotionActions.empty()) {
qDeleteAll(m_promotionActions);
m_promotionActions.clear();
}
// No promotion of main container
if (formWindow->mainContainer() == m_widget)
return NotApplicable;
// Check for a homogenous selection
const PromotionSelectionList promotionSelection = promotionSelectionList(formWindow);
if (promotionSelection.empty())
return NoHomogenousSelection;
QDesignerFormEditorInterface *core = formWindow->core();
// if it is promoted: demote only.
if (isPromoted(formWindow->core(), m_widget)) {
const QString label = m_demoteLabel.arg( promotedExtends(core , m_widget));
QAction *demoteAction = new QAction(label, this);
connect(demoteAction, SIGNAL(triggered()), this, SLOT(slotDemoteFromCustomWidget()));
m_promotionActions.push_back(demoteAction);
return CanDemote;
}
// figure out candidates
const QString baseClassName = WidgetFactory::classNameOf(core, m_widget);
const WidgetDataBaseItemList candidates = promotionCandidates(core->widgetDataBase(), baseClassName );
if (candidates.empty()) {
// Is this thing promotable at all?
return QDesignerPromotionDialog::baseClassNames(core->promotion()).contains(baseClassName) ? CanPromote : NotApplicable;
}
// Set up a signal mapper to associate class names
if (!m_promotionMapper) {
m_promotionMapper = new QSignalMapper(this);
connect(m_promotionMapper, SIGNAL(mapped(QString)), this, SLOT(slotPromoteToCustomWidget(QString)));
}
QMenu *candidatesMenu = new QMenu();
// Create a sub menu
const WidgetDataBaseItemList::const_iterator cend = candidates.constEnd();
// Set up actions and map class names
for (WidgetDataBaseItemList::const_iterator it = candidates.constBegin(); it != cend; ++it) {
const QString customClassName = (*it)->name();
QAction *action = new QAction((*it)->name(), this);
connect(action, SIGNAL(triggered()), m_promotionMapper, SLOT(map()));
m_promotionMapper->setMapping(action, customClassName);
candidatesMenu->addAction(action);
}
// Sub menu action
QAction *subMenuAction = new QAction(m_promoteLabel, this);
subMenuAction->setMenu(candidatesMenu);
m_promotionActions.push_back(subMenuAction);
return CanPromote;
}
示例12: QMainWindow
QtGnuplotWindow::QtGnuplotWindow(int id, QtGnuplotEventHandler* eventHandler, QWidget* parent)
: QMainWindow(parent)
{
m_eventHandler = eventHandler;
m_id = id;
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":/images/gnuplot"));
// Register as the main event receiver if not already created
if (m_eventHandler == 0)
m_eventHandler = new QtGnuplotEventHandler(this,
"qtgnuplot" + QString::number(QCoreApplication::applicationPid()));
// Central widget
m_widget = new QtGnuplotWidget(m_id, m_eventHandler, this);
connect(m_widget, SIGNAL(statusTextChanged(const QString&)), this, SLOT(on_setStatusText(const QString&)));
setCentralWidget(m_widget);
// Bars
m_toolBar = new QToolBar(this);
addToolBar(m_toolBar);
statusBar()->showMessage(tr("Qt frontend for gnuplot"));
// Actions
QAction* copyToClipboardAction = new QAction(QIcon(":/images/clipboard" ), tr("Copy to clipboard"), this);
QAction* printAction = new QAction(QIcon(":/images/print" ), tr("Print" ), this);
QAction* exportAction = new QAction(QIcon(":/images/export" ), tr("Export" ), this);
QAction* exportPdfAction = new QAction(QIcon(":/images/exportPDF" ), tr("Export to PDF" ), this);
QAction* exportEpsAction = new QAction(QIcon(":/images/exportVector"), tr("Export to EPS" ), this);
QAction* exportSvgAction = new QAction(QIcon(":/images/exportVector"), tr("Export to SVG" ), this);
QAction* exportPngAction = new QAction(QIcon(":/images/exportRaster"), tr("Export to image" ), this);
QAction* settingsAction = new QAction(QIcon(":/images/settings" ), tr("Settings" ), this);
connect(copyToClipboardAction, SIGNAL(triggered()), m_widget, SLOT(copyToClipboard()));
connect(printAction, SIGNAL(triggered()), m_widget, SLOT(print()));
connect(exportPdfAction, SIGNAL(triggered()), m_widget, SLOT(exportToPdf()));
connect(exportEpsAction, SIGNAL(triggered()), m_widget, SLOT(exportToEps()));
connect(exportSvgAction, SIGNAL(triggered()), m_widget, SLOT(exportToSvg()));
connect(exportPngAction, SIGNAL(triggered()), m_widget, SLOT(exportToImage()));
connect(settingsAction, SIGNAL(triggered()), m_widget, SLOT(showSettingsDialog()));
QMenu* exportMenu = new QMenu(this);
exportMenu->addAction(copyToClipboardAction);
exportMenu->addAction(printAction);
exportMenu->addAction(exportPdfAction);
// exportMenu->addAction(exportEpsAction);
exportMenu->addAction(exportSvgAction);
exportMenu->addAction(exportPngAction);
exportAction->setMenu(exportMenu);
m_toolBar->addAction(exportAction);
createAction(tr("Replot") , 'e', ":/images/replot");
createAction(tr("Show grid") , 'g', ":/images/grid");
createAction(tr("Previous zoom"), 'p', ":/images/zoomPrevious");
createAction(tr("Next zoom") , 'n', ":/images/zoomNext");
createAction(tr("Autoscale") , 'a', ":/images/autoscale");
m_toolBar->addAction(settingsAction);
}
示例13: QDesignerTaskMenu
ContainerWidgetTaskMenu::ContainerWidgetTaskMenu(QWidget *widget, ContainerType type, QObject *parent) :
QDesignerTaskMenu(widget, parent),
m_type(type),
m_containerWidget(widget),
m_core(formWindow()->core()),
m_pagePromotionTaskMenu(new PromotionTaskMenu(0, PromotionTaskMenu::ModeSingleWidget, this)),
m_pageMenuAction(new QAction(this)),
m_pageMenu(new QMenu),
m_actionInsertPageAfter(new QAction(this)),
m_actionInsertPage(0),
m_actionDeletePage(new QAction(tr("Delete"), this))
{
Q_ASSERT(m_core);
m_taskActions.append(createSeparator());
connect(m_actionDeletePage, SIGNAL(triggered()), this, SLOT(removeCurrentPage()));
connect(m_actionInsertPageAfter, SIGNAL(triggered()), this, SLOT(addPageAfter()));
// Empty Per-Page submenu, deletion and promotion. Updated on demand due to promotion state
switch (m_type) {
case WizardContainer:
case PageContainer:
m_taskActions.append(createSeparator()); // for the browse actions
break;
case MdiContainer:
break;
}
// submenu
m_pageMenuAction->setMenu(m_pageMenu);
m_taskActions.append(m_pageMenuAction);
// Insertion
switch (m_type) {
case WizardContainer:
case PageContainer: { // Before and after in a submenu
QAction *insertMenuAction = new QAction(tr("Insert"), this);
QMenu *insertMenu = new QMenu;
// before
m_actionInsertPage = new QAction(tr("Insert Page Before Current Page"), this);
connect(m_actionInsertPage, SIGNAL(triggered()), this, SLOT(addPage()));
insertMenu->addAction(m_actionInsertPage);
// after
m_actionInsertPageAfter->setText(tr("Insert Page After Current Page"));
insertMenu->addAction(m_actionInsertPageAfter);
insertMenuAction->setMenu(insertMenu);
m_taskActions.append(insertMenuAction);
}
break;
case MdiContainer: // No concept of order
m_actionInsertPageAfter->setText(tr("Add Subwindow"));
m_taskActions.append(m_actionInsertPageAfter);
break;
}
}
示例14: init
void IndiWidgetGroup::init()
{
// Create the context menu actions
QMenu* menu = new QMenu(this);
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(changeWindowCount(QAction*)));
QAction* act;
act = menu->addAction("+1");
act->setData(1);
act = menu->addAction("+2");
act->setData(2);
act = menu->addAction("+3");
act->setData(3);
act = new QAction(tr("More Indicators..."), this);
act->setMenu(menu);
addAction(act);
menu = new QMenu(this);
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(changeWindowCount(QAction*)));
act = menu->addAction("-1");
act->setData(-1);
act = menu->addAction("-2");
act->setData(-2);
act = menu->addAction("-3");
act->setData(-3);
act = new QAction(tr("Less Indicators..."), this);
act->setMenu(menu);
addAction(act);
mFullIndiSetsPath = mRcFile->getPath("IndiSetsPath");
mSplitter = new QSplitter(Qt::Vertical);
QVBoxLayout* lay = new QVBoxLayout;
lay->addWidget(mSplitter);
setLayout(lay);
}
示例15: event
bool Module::event(QEvent *ev)
{
if (ev->type() == ActionCreatedEvent::eventType()) {
ActionCreatedEvent *event = static_cast<ActionCreatedEvent*>(ev);
if (event->generator() == p->tagsGenerator.data()) {
QAction *action = event->action();
QMenu *menu = new QMenu(p->widget);
QAction *act = menu->addAction(tr("Select tags"));
connect(act, SIGNAL(triggered()), this, SLOT(onSelectTagsTriggered()));
act = menu->addAction(tr("Reset"));
connect(act, SIGNAL(triggered()), this, SLOT(onResetTagsTriggered()));
action->setMenu(menu);
}
}
return QObject::event(ev);
}