本文整理汇总了C++中QAction::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setData方法的具体用法?C++ QAction::setData怎么用?C++ QAction::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showWorkspaceMenu
void MuseScore::showWorkspaceMenu()
{
if (workspaces == 0) {
workspaces = new QActionGroup(this);
workspaces->setExclusive(true);
connect(workspaces, SIGNAL(triggered(QAction*)), SLOT(changeWorkspace(QAction*)));
}
else {
foreach(QAction* a, workspaces->actions())
workspaces->removeAction(a);
}
menuWorkspaces->clear();
const QList<Workspace*> pl = Workspace::workspaces();
foreach (Workspace* p, pl) {
QAction* a = workspaces->addAction(p->name());
a->setCheckable(true);
a->setData(p->path());
a->setChecked(a->text() == preferences.workspace);
menuWorkspaces->addAction(a);
}
示例2: createWidgetForFlags
QWidget* PropertyEditor::createWidgetForFlags(const QString& name, const QVariant& value, QMetaEnum me, const QString &detail, QWidget* parent)
{
mProperties[name] = value;
QToolButton *btn = new QToolButton(parent);
if (!detail.isEmpty())
btn->setToolTip(detail);
btn->setObjectName(name);
btn->setText(QObject::tr(name.toUtf8().constData()));
btn->setPopupMode(QToolButton::InstantPopup);
ClickableMenu *menu = new ClickableMenu(btn);
menu->setObjectName(name);
btn->setMenu(menu);
for (int i = 0; i < me.keyCount(); ++i) {
QAction * a = menu->addAction(me.key(i));
a->setCheckable(true);
a->setData(me.value(i));
a->setChecked(value.toInt() & me.value(i));
}
connect(menu, SIGNAL(triggered(QAction*)), SLOT(onFlagChange(QAction*)));
return btn;
}
示例3: populateRecentFileMenuItems
void LDViewMainWindow::populateRecentFileMenuItems(void)
{
#ifdef __APPLE__
if (!openRecentMenu)
{
return;
}
#endif // __APPLE__
clearRecentFileMenuItems();
if (recentFiles->stringAtIndex(0))
{
int i;
long maxRecentFiles = Preferences::getMaxRecentFiles();
for (i = 0; i < maxRecentFiles; i++)
{
char *filename = truncateFilename(recentFiles->stringAtIndex(i));
if (filename)
{
#ifdef __APPLE__
QMenu *menu = openRecentMenu;
#else // __APPLE__
QMenu *menu = fileMenu;
#endif // __APPLE__
QAction *act;
act = new QAction(filename,this);
act->setData(i);
menu->insertAction(fileMenu->actions()[fileMenu->actions().count() - 1],
act);
connect( act, SIGNAL( triggered() ), this, SLOT(doRecentFile()) );
delete filename;
}
}
#ifndef __APPLE__
fileMenu->insertSeparator(fileMenu->actions()[fileMenu->actions().count() - 1]);
#endif // __APPLE__
}
}
示例4: index
QMenu *BrowserWindow::createWindowMenu(TabWidget *tabWidget)
{
QMenu *menu = new QMenu(tr("&Window"));
QAction *nextTabAction = new QAction(tr("Show Next Tab"), this);
QList<QKeySequence> shortcuts;
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less));
nextTabAction->setShortcuts(shortcuts);
connect(nextTabAction, &QAction::triggered, tabWidget, &TabWidget::nextTab);
QAction *previousTabAction = new QAction(tr("Show Previous Tab"), this);
shortcuts.clear();
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft));
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater));
previousTabAction->setShortcuts(shortcuts);
connect(previousTabAction, &QAction::triggered, tabWidget, &TabWidget::previousTab);
connect(menu, &QMenu::aboutToShow, [this, menu, nextTabAction, previousTabAction]() {
menu->clear();
menu->addAction(nextTabAction);
menu->addAction(previousTabAction);
menu->addSeparator();
QVector<BrowserWindow*> windows = Browser::instance().windows();
int index(-1);
for (auto window : windows) {
QAction *action = menu->addAction(window->windowTitle(), this, &BrowserWindow::handleShowWindowTriggered);
action->setData(++index);
action->setCheckable(true);
if (window == this)
action->setChecked(true);
}
});
return menu;
}
示例5: buildResolutionLevelMenu
void ossimQtSingleImageWindow::buildResolutionLevelMenu()
{
if (!theResolutionLevelMenu) return;
ossim_uint32 count = theResolutionLevelMenu->count();
ossim_uint32 numberOfReducedResSets = 1;
ossimRLevelFilter* rf = getRLevelFilter();
if (rf)
{
numberOfReducedResSets = rf->getNumberOfDecimationLevels();
}
if (count != numberOfReducedResSets)
{
theResolutionLevelMenu->clear();
QActionGroup* rsetGroup = new QActionGroup(theResolutionLevelMenu);
for (ossim_uint32 i = 0; i < numberOfReducedResSets; ++i)
{
int id = static_cast<int>(i);
QString qs = ossimString::toString(i).c_str();
//---
//Create the QAction button (Rset button) and assign it to the
// rset group so that only one Rset is checked at any given time.
//---
QAction* rsetAct = new QAction(qs, rsetGroup);
rsetAct->setCheckable(true);
//Set the Rset 0 button to checked upon initial entry
if (i == 0)rsetAct->setChecked(true);
rsetAct->setData(id);
rsetAct->setEnabled(true);
theResolutionLevelMenu->addAction( rsetAct );
rsetGroup->addAction( rsetAct );
}
}
}
示例6: langListSync
void MainWindow::langListSync()
{
// format systems language
ui->menuLanguage->clear();
QDir dir(m_langPath);
QStringList fileNames = dir.entryList(QStringList("editor_*.qm"));
for (int i = 0; i < fileNames.size(); ++i)
{
// get locale extracted by filename
QString locale;
locale = fileNames[i]; // "TranslationExample_de.qm"
locale.truncate(locale.lastIndexOf('.')); // "TranslationExample_de"
locale.remove(0, locale.indexOf('_') + 1); // "de"
QString lang = QLocale::languageToString(QLocale(locale).language());
QIcon ico(QString("%1/%2.png").arg(m_langPath).arg(locale));
QAction *action = new QAction(ico, lang, this);
action->setCheckable(true);
action->setData(locale);
WriteToLog(QtDebugMsg, QString("Locale: %1 %2").arg(m_langPath).arg(locale));
ui->menuLanguage->addAction(action);
if (GlobalSettings::locale == locale)
{
action->setChecked(true);
}
}
if(fileNames.size()==0)
{
QAction *action = ui->menuLanguage->addAction("[translations not found]");
action->setCheckable(false);
action->setDisabled(true);
}
}
示例7: QToolButton
QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();
QToolButton *toolButton = nullptr;
QWidget *container = nullptr;
if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
{
toolButton = new QToolButton();
toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
toolButton->setPopupMode( QToolButton::MenuButtonPopup );
container = toolButton;
}
else
{
container = new QWidget();
container->setLayout( new QHBoxLayout() );
container->layout()->setMargin( 0 );
}
QList< QAction * > actionList;
QAction *defaultAction = nullptr;
// first add user created layer actions
QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
Q_FOREACH ( const QgsAction &action, actions )
{
QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QLatin1String( "" );
QAction *act = new QAction( action.icon(), actionTitle, container );
act->setToolTip( action.name() );
act->setData( "user_action" );
act->setProperty( "fid", fid );
act->setProperty( "action_id", action.id() );
connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
actionList << act;
if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "AttributeTableRow" ) ).id() == action.id() )
defaultAction = act;
}
示例8: NoteWidget
/**
* Constructeur
* @param parent Parent du widget
*/
DocumentWidget::DocumentWidget(QWidget *parent) :
NoteWidget(parent)
{
//Construction du layout du widget
QVBoxLayout *layout = new QVBoxLayout;
//Construction de l'edition du titre du document
titleEdit = new QLineEdit;
connect(titleEdit,SIGNAL(textChanged(QString)),this,SLOT(changeTitle(QString)));
layout->addWidget(titleEdit,1,Qt::AlignTop);
// QScrollArea *scroll = new QScrollArea();
// QWidget *childrenWidget = new QWidget();
childrenLayout = new QVBoxLayout;
layout->addLayout(childrenLayout);
//Construction du menu associé au bouton "ajouter"
noteTypeMenu = new QMenu(tr("..."));
QMap<QString, NoteFactory*> &factories = NotesManager::getInstance()->getFactories();
QMap<QString, NoteFactory*>::iterator it = factories.begin();
QMap<QString, NoteFactory*>::iterator end = factories.end();
while (it != end) {
if (*it) {
QAction *newNote = noteTypeMenu->addAction((*it)->getName());
newNote->setData(it.key());
newNote->setIcon(QIcon((*it)->getIcon()));
connect(newNote,SIGNAL(triggered()),this,SLOT(addChild()));
}
it++;
}
QPushButton *more = new QPushButton(tr("Add child"));
more->setMenu(noteTypeMenu);
layout->addWidget(more,0,Qt::AlignBottom);
setLayout(layout);
}
示例9: PopupMenuControlEntries
void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
{
QAction *action;
/* Faster/Slower */
action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(),
SLOT( faster() ) );
action->setIcon( QIcon( ":/toolbar/faster") );
action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(),
SLOT( littlefaster() ) );
action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(),
SLOT( normalRate() ) );
action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(),
SLOT( littleslower() ) );
action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(),
SLOT( slower() ) );
action->setIcon( QIcon( ":/toolbar/slower") );
action->setData( STATIC_ENTRY );
menu->addSeparator();
action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(),
SLOT( jumpFwd() ) );
action->setIcon( QIcon( ":/toolbar/skip_fw") );
action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(),
SLOT( jumpBwd() ) );
action->setIcon( QIcon( ":/toolbar/skip_back") );
action->setData( STATIC_ENTRY );
addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
SLOT( gotoTimeDialog() ), "Ctrl+T" );
menu->addSeparator();
}
示例10: setModule
void ProtocolPreferencesMenu::setModule(const char *module_name)
{
QAction *action;
int proto_id = -1;
protocol_t *protocol;
clear();
module_name_.clear();
module_ = NULL;
if (module_name) {
proto_id = proto_get_id_by_filter_name(module_name);
protocol = find_protocol_by_id(proto_id);
}
if (proto_id < 0 || !protocol) {
action = addAction(tr("No protocol preferences available"));
action->setDisabled(true);
return;
}
module_ = prefs_find_module(module_name);
const QString proto_name = proto_get_protocol_long_name(protocol);
if (!module_ || !prefs_is_registered_protocol(module_name)) {
action = addAction(tr("%1 has no preferences").arg(proto_name));
action->setDisabled(true);
return;
}
module_name_ = module_name;
action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name));
action->setData(QString(module_name));
connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered()));
addSeparator();
prefs_pref_foreach(module_, add_prefs_menu_item, this);
}
示例11: create_menu_from_dir_dir
//uses dir name as menuitem, no recursion
void create_menu_from_dir_dir (QObject *handler,
QMenu *menu,
const QString &dir,
const char *method
)
{
menu->setTearOffEnabled (true);
QDir d (dir);
QFileInfoList lst_fi = d.entryInfoList (QDir::NoDotAndDotDot | QDir::Dirs,
QDir::IgnoreCase | QDir::LocaleAware | QDir::Name);
foreach (QFileInfo fi, lst_fi)
{
if (fi.isDir())
{
QAction *act = new QAction (fi.fileName(), menu->parentWidget());
act->setData (fi.filePath());
handler->connect (act, SIGNAL(triggered()), handler, method);
menu->addAction (act);
}
}
}
示例12: add
void DocumentManager::add(DocumentInfo *documentInfo)
{
QMainWindow *mainWindow = documentInfo->mainWindow;
d->documentInfos.append(documentInfo);
connect(mainWindow, SIGNAL(destroyed(QObject *)),
this, SLOT(remove(QObject *)));
// update object name ("window ID")
mainWindow->setObjectName(mainWindow->objectName() + QString::number(d->nextWindowId));
mainWindow->installEventFilter(this);
/*!\todo This gets messy: make DocumentInfo a proper class. */
documentInfo->id = d->nextWindowId;
++d->nextWindowId;
documentInfo->windowTitle = tr("New %1", "New document title + ID").arg(d->nextWindowId);
QAction *action = new QAction(d->windowActionGroup);
action->setCheckable(true);
action->setData(documentInfo->id);
action->setText(documentInfo->windowTitle);
d->windowMapper.setMapping(action, documentInfo->id);
connect(action, SIGNAL(triggered()),
&d->windowMapper, SLOT(map()));
emit changed();
}
示例13: aboutToShowRecentPatients
/** \brief Rebuild the patients' history menu */
void PatientActionHandler::aboutToShowRecentPatients()
{
// update patient history
Core::ActionContainer *recentsMenu = actionManager()->actionContainer(Core::Constants::M_PATIENTS_NAVIGATION);
if (!recentsMenu)
return;
if (!recentsMenu->menu())
return;
recentsMenu->menu()->clear();
bool hasRecentFiles = false;
const QStringList &uuids = m_RecentPatients->recentFiles();
const QHash<QString, QString> &names = patient()->fullPatientName(uuids);
for(int i = 0; i < uuids.count(); ++i) {
hasRecentFiles = true;
QAction *action = recentsMenu->menu()->addAction(tkTr(Trans::Constants::_1_COLON_2).arg(i).arg(names.value(uuids.at(i))));
action->setData(uuids.at(i));
connect(action, SIGNAL(triggered()), this, SLOT(openRecentPatient()));
}
recentsMenu->menu()->setEnabled(hasRecentFiles);
}
示例14: addMIMStaticEntry
/**
* @brief Add static entries to MIM in menus
**/
QAction* addMIMStaticEntry( intf_thread_t *p_intf,
QMenu *menu,
const QString& text,
const char *icon,
const char *member,
bool bStatic = false )
{
QAction *action;
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
if( !EMPTY_STR( icon ) )
{
action = menu->addAction( text, THEMIM, member );
action->setIcon( QIcon( icon ) );
}
else
#endif
{
action = menu->addAction( text, THEMIM, member );
}
action->setData( bStatic ? STATIC_ENTRY : ENTRY_ALWAYS_ENABLED );
return action;
}
示例15: setModel
void PlaylistHeaderView::setModel(QAbstractItemModel *model)
{
QHeaderView::setModel(model);
for (int i = 0; i < count(); i++) {
QString label = labels.at(i);
// Exclude hidden columns (should be improved?)
if (QString::compare(label, "TrackDAO") != 0) {
model->setHeaderData(i, Qt::Horizontal, tr(label.toStdString().data()), Qt::DisplayRole);
// Match actions with columns using index of labels
QAction *actionColumn = new QAction(label, this);
actionColumn->setData(i);
actionColumn->setEnabled(actionColumn->text() != tr("Title"));
actionColumn->setCheckable(true);
actionColumn->setChecked(!isSectionHidden(i));
// Then populate the context menu
_columns->addAction(actionColumn);
}
}
}