本文整理汇总了C++中QMenu::setTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::setTitle方法的具体用法?C++ QMenu::setTitle怎么用?C++ QMenu::setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: customMenu
QMenu* VCFrame::customMenu(QMenu* parentMenu)
{
/* No point coming here if there is no VC */
VirtualConsole* vc = VirtualConsole::instance();
if (vc == NULL)
return NULL;
/* Basically, just returning VC::addMenu() would suffice here, but
since the returned menu will be deleted when the current widget
changes, we have to copy the menu's contents into a new menu. */
QMenu* menu = new QMenu(parentMenu);
menu->setTitle(tr("Add"));
QListIterator <QAction*> it(vc->addMenu()->actions());
while (it.hasNext() == true)
menu->addAction(it.next());
return menu;
}
示例2: contextMenuEvent
void InputField::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *editMenu = createStandardContextMenu();
editMenu->setTitle(tr("Edit"));
QMenu* menu = new QMenu(QString::fromAscii("InputFieldContextmenu"));
menu->addMenu(editMenu);
menu->addSeparator();
// datastructure to remember actions for values
std::vector<QString> values;
std::vector<QAction *> actions;
// add the history menu part...
std::vector<QString> history = getHistory();
for(std::vector<QString>::const_iterator it = history.begin();it!= history.end();++it){
actions.push_back(menu->addAction(*it));
values.push_back(*it);
}
// add the save value portion of the menu
menu->addSeparator();
QAction *SaveValueAction = menu->addAction(tr("Save value"));
std::vector<QString> savedValues = getSavedValues();
for(std::vector<QString>::const_iterator it = savedValues.begin();it!= savedValues.end();++it){
actions.push_back(menu->addAction(*it));
values.push_back(*it);
}
// call the menu and wait until its back
QAction *saveAction = menu->exec(event->globalPos());
// look what the user has choosen
if(saveAction == SaveValueAction)
pushToSavedValues();
else{
int i=0;
for(std::vector<QAction *>::const_iterator it = actions.begin();it!=actions.end();++it,i++)
if(*it == saveAction)
this->setText(values[i]);
}
delete menu;
}
示例3: genItemPopup
QMenu* EventCanvas::genItemPopup(CItem* item)/*{{{*/
{
QMenu* notePopup = new QMenu(this);
QMenu* colorPopup = notePopup->addMenu(tr("Part Color"));
QMenu* colorSub;
for (int i = 0; i < NUM_PARTCOLORS; ++i)
{
QString colorname(config.partColorNames[i]);
if(colorname.contains("menu:", Qt::CaseSensitive))
{
colorSub = colorPopup->addMenu(colorname.replace("menu:", ""));
}
else
{
if(item->part()->colorIndex() == i)
{
colorname = QString(config.partColorNames[i]);
colorPopup->setIcon(partColorIcons.at(i));
colorPopup->setTitle(colorSub->title()+": "+colorname);
colorname = QString("* "+config.partColorNames[i]);
QAction *act_color = colorSub->addAction(partColorIcons.at(i), colorname);
act_color->setData(20 + i);
}
else
{
colorname = QString(" "+config.partColorNames[i]);
QAction *act_color = colorSub->addAction(partColorIcons.at(i), colorname);
act_color->setData(20 + i);
}
}
}
notePopup->addSeparator();
for (unsigned i = 0; i < 9; ++i)
{
if ((_canvasTools & (1 << i)) == 0)
continue;
QAction* act = notePopup->addAction(QIcon(*toolList[i].icon), tr(toolList[i].tip));
act->setData(1 << i);
}
return notePopup;
}/*}}}*/
示例4: initialize
/*! Initializes the plugin. Returns true on success.
Plugins want to register objects with the plugin manager here.
\a errorMessage can be used to pass an error message to the plugin system,
if there was any.
*/
bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
// Get the primary access point to the workbench.
Core::ICore *core = Core::ICore::instance();
// Create a unique context for our own view, that will be used for the
// menu entry later.
Core::Context context("HelloWorld.MainView");
// Create an action to be triggered by a menu entry
QAction *helloWorldAction = new QAction(tr("Say \"&Hello World!\""), this);
connect(helloWorldAction, SIGNAL(triggered()), SLOT(sayHelloWorld()));
// Register the action with the action manager
Core::ActionManager *actionManager = core->actionManager();
Core::Command *command =
actionManager->registerAction(
helloWorldAction, "HelloWorld.HelloWorldAction", context);
// Create our own menu to place in the Tools menu
Core::ActionContainer *helloWorldMenu =
actionManager->createMenu("HelloWorld.HelloWorldMenu");
QMenu *menu = helloWorldMenu->menu();
menu->setTitle(tr("&Hello World"));
menu->setEnabled(true);
// Add the Hello World action command to the menu
helloWorldMenu->addAction(command);
// Request the Tools menu and add the Hello World menu to it
Core::ActionContainer *toolsMenu =
actionManager->actionContainer(Core::Constants::M_TOOLS);
toolsMenu->addMenu(helloWorldMenu);
// Add a mode with a push button based on BaseMode. Like the BaseView,
// it will unregister itself from the plugin manager when it is deleted.
Core::IMode *helloMode = new HelloMode;
addAutoReleasedObject(helloMode);
return true;
}
示例5: createMenu
void BazaarPlugin::createMenu()
{
Core::Context context(Core::Constants::C_GLOBAL);
// Create menu item for Bazaar
m_bazaarContainer = m_actionManager->createMenu(Core::Id("Bazaar.BazaarMenu"));
QMenu *menu = m_bazaarContainer->menu();
menu->setTitle(tr("Bazaar"));
createFileActions(context);
createSeparator(context, Core::Id("Bazaar.FileDirSeperator"));
createDirectoryActions(context);
createSeparator(context, Core::Id("Bazaar.DirRepoSeperator"));
createRepositoryActions(context);
createSeparator(context, Core::Id("Bazaar.Repository Management"));
// Request the Tools menu and add the Bazaar menu to it
Core::ActionContainer *toolsMenu = m_actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
toolsMenu->addMenu(m_bazaarContainer);
m_menuAction = m_bazaarContainer->menu()->menuAction();
}
示例6: shot
void MetamenuPlugin::shot() {
QWidget* window = oneOfChatWindows();
if(!m_menuBar && window)
QMetaObject::invokeMethod(window, "getMenuBar", Q_RETURN_ARG(QMenuBar*, m_menuBar));
QMenu* mainMenu = m_menu->menu(false);
mainMenu->setTitle("&qutIM");
if(m_menuBar && !m_added) {
qDebug() << mainMenu;
m_menuBar->addMenu(mainMenu);
m_added = true;
}
if(!m_added)
QTimer::singleShot(1000, this, SLOT(shot()));
else
connect(window, SIGNAL(destroyed()), this, SLOT(onDestroyed()));
}
示例7: mountImage
void MainWindow::mountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
image_interface_iterator iter(m_machine->root_device());
device_image_interface *img = iter.byindex(imageIndex);
if (img == nullptr)
{
m_machine->debugger().console().printf("Something is wrong with the mount menu.\n");
refreshAll();
return;
}
// File dialog
QString filename = QFileDialog::getOpenFileName(this,
"Select an image file",
QDir::currentPath(),
tr("All files (*.*)"));
if (img->load(filename.toUtf8().data()) != image_init_result::PASS)
{
m_machine->debugger().console().printf("Image could not be mounted.\n");
refreshAll();
return;
}
// Activate the unmount menu option
QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount");
unmountAct->setEnabled(true);
// Set the mount name
QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle);
m_machine->debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
refreshAll();
}
示例8: unmountImage
void MainWindow::unmountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
image_interface_iterator iter(m_machine->root_device());
device_image_interface *img = iter.byindex(imageIndex);
img->unload();
// Deactivate the unmount menu option
dynamic_cast<QAction*>(sender())->setEnabled(false);
// Set the mount name
QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle);
m_machine->debugger().console().printf("Image successfully unmounted.\n");
refreshAll();
}
示例9: displayContentTreeMenu
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
{
QMenu myFilesLlistMenu;
const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0);
QAction *actRename = 0;
if (selectedRows.size() == 1) {
actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
myFilesLlistMenu.addSeparator();
}
QMenu subMenu;
subMenu.setTitle(tr("Priority"));
subMenu.addAction(ui->actionNot_downloaded);
subMenu.addAction(ui->actionNormal);
subMenu.addAction(ui->actionHigh);
subMenu.addAction(ui->actionMaximum);
myFilesLlistMenu.addMenu(&subMenu);
// Call menu
QAction *act = myFilesLlistMenu.exec(QCursor::pos());
if (act) {
if (act == actRename) {
renameSelectedFile();
}
else {
int prio = prio::NORMAL;
if (act == ui->actionHigh)
prio = prio::HIGH;
else if (act == ui->actionMaximum)
prio = prio::MAXIMUM;
else if (act == ui->actionNot_downloaded)
prio = prio::IGNORED;
qDebug("Setting files priority");
foreach (const QModelIndex &index, selectedRows) {
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
m_contentModel->setData(m_contentModel->index(index.row(), PRIORITY, index.parent()), prio);
}
}
}
示例10: leaveEditMode
void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode)
{
m_editor->releaseKeyboard();
if (mode == Default)
return;
if (m_editor->text().isEmpty())
return;
QAction *action = 0;
QDesignerFormWindowInterface *fw = formWindow();
Q_ASSERT(fw);
if (m_currentIndex >= 0 && m_currentIndex < realActionCount()) {
action = safeActionAt(m_currentIndex);
fw->beginCommand(QApplication::translate("Command", "Change Title"));
} else {
fw->beginCommand(QApplication::translate("Command", "Insert Menu"));
const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu"));
QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this));
fw->core()->widgetFactory()->initialize(menu);
menu->setObjectName(niceObjectName);
menu->setTitle(tr("Menu"));
fw->ensureUniqueObjectName(menu);
action = menu->menuAction();
AddMenuActionCommand *cmd = new AddMenuActionCommand(fw);
cmd->init(action, m_addMenu, this, this);
fw->commandHistory()->push(cmd);
}
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
cmd->init(action, QStringLiteral("text"), m_editor->text());
fw->commandHistory()->push(cmd);
fw->endCommand();
}
示例11: initialize
bool ColorPickerPlugin::initialize(const QStringList &arguments,
QString *errorMessage)
{
Q_UNUSED(arguments);
Q_UNUSED(errorMessage);
auto optionsPage = new ColorPickerOptionsPage;
d->generalSettings = optionsPage->generalSettings();
connect(optionsPage, &ColorPickerOptionsPage::generalSettingsChanged,
this, &ColorPickerPlugin::onGeneralSettingsChanged);
// Register the plugin actions
ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *myContainer = ActionManager::createMenu("ColorPicker");
QMenu *myMenu = myContainer->menu();
myMenu->setTitle(tr("&ColorPicker"));
myMenu->setEnabled(true);
auto triggerColorEditAction = new QAction(tr(Constants::ACTION_NAME_TRIGGER_COLOR_EDIT), this);
Command *command = ActionManager::registerAction(triggerColorEditAction,
Constants::TRIGGER_COLOR_EDIT);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+C")));
myContainer->addAction(command);
connect(triggerColorEditAction, &QAction::triggered,
this, &ColorPickerPlugin::onColorEditTriggered);
toolsContainer->addMenu(myContainer);
// Register objects
addAutoReleasedObject(optionsPage);
return true;
}
示例12: QMenu
/**
* Service Discovery SubMenu
**/
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
{
QMenu *menu = new QMenu( parent );
menu->setTitle( qtr( I_PL_SD ) );
char **ppsz_longnames;
char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
if( !ppsz_names )
return menu;
char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
{
QAction *a = new QAction( qfu( *ppsz_longname ), menu );
a->setCheckable( true );
if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
a->setChecked( true );
CONNECT( a, triggered(), THEDP->SDMapper, map() );
THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
menu->addAction( a );
/* Special case for podcast */
if( !strcmp( *ppsz_name, "podcast" ) )
{
QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
//b->setEnabled( a->isChecked() );
menu->addAction( b );
CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
}
free( *ppsz_name );
free( *ppsz_longname );
}
free( ppsz_names );
free( ppsz_longnames );
return menu;
}
示例13: displayData
QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));
QMenu *childMenu = new QMenu(parentMenu);
// Set text:
if (displayData.canConvert(QVariant::String)) {
childMenu->setTitle(displayData.toString());
}
// Set icon:
if (iconData.canConvert(QVariant::Icon)) {
childMenu->setIcon(iconData.value<QIcon>());
}
// Set tooltip:
if (toolTipData.canConvert(QVariant::String)) {
childMenu->setToolTip(toolTipData.toString());
}
// Set status tip:
if (statusTipData.canConvert(QVariant::String)) {
childMenu->setStatusTip(statusTipData.toString());
}
// Set whatsthis:
if (whatsThisData.canConvert(QVariant::String)) {
childMenu->setWhatsThis(whatsThisData.toString());
}
return childMenu;
}
示例14: Home
void pdp::MainWindow::setupUi() {
// Add back button
QPushButton* back = new QPushButton(QIcon(":/common/res/common/back.png"), QApplication::translate("MainWindow", "Zur\303\274ck", 0, QApplication::UnicodeUTF8));
ui_main.tabWidget->setCornerWidget(back, Qt::TopRightCorner);
QObject::connect(back, SIGNAL(clicked()), this, SLOT(onBack()));
// Add the "start" tab.
new pdp::Home(this->ui_main.tabWidget, this);
// Creates progressDialog
m_progressDialog = new QProgressDialog("", QString(), 0, 100, this);
m_progressDialog->setMinimumDuration(0);
//m_progressDialog->setWindowModality(Qt::WindowModal);
// Correction of automatic segmentation via 3d interactive segmentation
m_NumberOfInstancesOfThreeDEditing = 0;
QMenu *menuWerkzeug;
menuWerkzeug = new QMenu(ui_main.menubar);
menuWerkzeug->setObjectName(QString::fromUtf8("menuWerkzeug"));
menuWerkzeug->setTitle(QApplication::translate("MainWindow", "Werkzeug", 0, QApplication::UnicodeUTF8));
ui_main.menubar->addMenu(menuWerkzeug);
QAction *actionThreeDEditing = new QAction(this);
actionThreeDEditing->setObjectName(QString::fromUtf8("actionThreeDEditing"));
actionThreeDEditing->setIconText("3DEditing");
QIcon icn_menu;
icn_menu.addFile(":/threeDEditing/res/threeDEditing/Rubber-32.png");
actionThreeDEditing->setIcon(icn_menu);
menuWerkzeug->addAction(actionThreeDEditing);
QObject::connect(actionThreeDEditing, SIGNAL(triggered()), this, SLOT(CreateThreeDEditing()));
// AutoRun
if(AUTO_IMPORT == 1)
CreateThreeDEditing();
}
示例15: createMenu
void MercurialPlugin::createMenu()
{
Core::Context context(Core::Constants::C_GLOBAL);
// Create menu item for Mercurial
mercurialContainer = actionManager->createMenu(Core::Id("Mercurial.MercurialMenu"));
QMenu *menu = mercurialContainer->menu();
menu->setTitle(tr("Mercurial"));
createFileActions(context);
createSeparator(context, Core::Id("Mercurial.FileDirSeperator"));
createDirectoryActions(context);
createSeparator(context, Core::Id("Mercurial.DirRepoSeperator"));
createRepositoryActions(context);
createSeparator(context, Core::Id("Mercurial.Repository Management"));
createRepositoryManagementActions(context);
createSeparator(context, Core::Id("Mercurial.LessUsedfunctionality"));
createLessUsedActions(context);
// Request the Tools menu and add the Mercurial menu to it
Core::ActionContainer *toolsMenu = actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
toolsMenu->addMenu(mercurialContainer);
m_menuAction = mercurialContainer->menu()->menuAction();
}