本文整理汇总了C++中QAction::icon方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::icon方法的具体用法?C++ QAction::icon怎么用?C++ QAction::icon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::icon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressEvent
void QCustomTreeWidget::mousePressEvent(QMouseEvent *e)
{
QTreeWidgetItem *item = itemAt(e->pos());
switch (e->button())
{
case Qt::LeftButton: if (item !=NULL)
{
bNewlySelected = !item->isSelected();
// the item will be selected (and not be unselected by mouseReleaseEvent)
}
QTreeWidget::mousePressEvent(e);
break;
case Qt::RightButton: if (item != NULL)
{
setCurrentItem(item);
QCustomTreeWidgetItem *qItem = dynamic_cast<QCustomTreeWidgetItem*>(item);
Item *treeItem = qItem->branch()->item();
QAction* action = menuIcons->exec(e->globalPos());
if (action == actionNone)
{
item->setIcon(1,QIcon());
treeItem->setState(Item::sNone);
}
else if (action == actionProgress)
{
item->setIcon(1,action->icon());
treeItem->setState(Item::sProgress);
}
else if (action == actionFailure)
{
item->setIcon(1,action->icon());
treeItem->setState(Item::sFailure);
}
else if (action == actionSuccess)
{
item->setIcon(1,action->icon());
treeItem->setState(Item::sSuccess);
}
else if (action == actionDelete)
{
deleteItem(item);
}
else if (action == actionAdd)
{
addItem(qItem);
}
}
else if (topLevelItemCount()==0)
{
addItem(NULL);
}
break;
default: break;
}
}
示例2: populateActionList
void ToolBarEditor::populateActionList(bool reset)
{
QStringList names = ActionManager::instance()->toolBarActionNames();
if(!reset)
{
QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
names = settings.value("Simple/toolbar_actions", names).toStringList();
}
for(int id = ActionManager::PLAY; id <= ActionManager::QUIT; ++id)
{
QAction *action = ACTION(id);
if(action->icon().isNull())
continue;
QListWidgetItem *item = new QListWidgetItem();
item->setIcon(action->icon());
item->setText(action->text().replace("&", ""));
item->setData(Qt::UserRole, action->objectName());
if(!names.contains(action->objectName()))
m_ui->actionsListWidget->addItem(item);
}
{
QListWidgetItem *item = new QListWidgetItem();
item->setText("-- " + tr("Separator") + " --");
item->setData(Qt::UserRole, "separator");
m_ui->actionsListWidget->addItem(item);
}
foreach (QString name, names)
{
QAction *action = ActionManager::instance()->findChild<QAction *>(name);
if(action)
{
QListWidgetItem *item = new QListWidgetItem();
item->setIcon(action->icon());
item->setText(action->text().replace("&", ""));
item->setData(Qt::UserRole, action->objectName());
m_ui->activeActionsListWidget->addItem(item);
}
else if(name == "separator")
{
QListWidgetItem *item = new QListWidgetItem();
item->setText("-- " + tr("Separator") + " --");
item->setData(Qt::UserRole, "separator");
m_ui->activeActionsListWidget->addItem(item);
}
}
示例3: initTable
void ShortcutsImpl::initTable(MainImpl *main)
{
QList<QObject*> childrens = main->children();
QListIterator<QObject*> iterator(childrens);
int row = 0;
while( iterator.hasNext() )
{
QObject *object = iterator.next();
QAction *action = qobject_cast<QAction*>(object);
if (action)
{
QString text = action->text().remove("&");
if ( !text.isEmpty() && !(action->data().toString().contains("Recent|")) )
{
QString shortcut = action->shortcut();
QTableWidgetItem *newItem = new QTableWidgetItem(text);
newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
newItem->setData(Qt::UserRole, addressToVariant(object));
newItem->setIcon(action->icon());
table->setRowCount(row+1);
table->setItem(row, 0, newItem);
table->setItem(row++, 1, new QTableWidgetItem(shortcut));
}
}
table->sortItems( 0 );
}
QHeaderView *header = table->horizontalHeader();
header->resizeSection( 0, 230 );
table->verticalHeader()->hide();
}
示例4: newNoteHeadsPalette
Palette* MuseScore::newNoteHeadsPalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Note Heads"));
sp->setMag(1.3);
sp->setGrid(33, 36);
sp->setDrawGrid(true);
for (int i = 0; i < int(NoteHead::Group::HEAD_GROUPS); ++i) {
SymId sym = Note::noteHead(0, NoteHead::Group(i), NoteHead::Type::HEAD_HALF);
// HEAD_BREVIS_ALT shows up only for brevis value
if (i == int(NoteHead::Group::HEAD_BREVIS_ALT) )
sym = Note::noteHead(0, NoteHead::Group(i), NoteHead::Type::HEAD_BREVIS);
NoteHead* nh = new NoteHead(gscore);
nh->setSym(sym);
sp->append(nh, Sym::id2userName(sym));
}
Icon* ik = new Icon(gscore);
ik->setIconType(IconType::BRACKETS);
Shortcut* s = Shortcut::getShortcut("add-brackets");
QAction* action = s->action();
QIcon icon(action->icon());
ik->setAction("add-brackets", icon);
sp->append(ik, s->help());
return sp;
}
示例5: QDialog
ToolbarDialog::ToolbarDialog(QWidget* parent)
: QDialog(parent),m_defaultToolBars()
{
setupUi(this);
createDefaultToolBars();
// populate all available actions
QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*"));
QAction* action;
foreach(action, actions) {
if (action->actionGroup()->objectName() != "extraGroup")
continue;
QListWidgetItem* item = new QListWidgetItem(action->toolTip());
item->setIcon(action->icon());
item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action));
listAllActions->addItem(item);
}
// Important to add special Separator
listAllActions->addItem("Separator");
QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>();
QToolBar* toolbar = NULL;
int index = 0;
foreach(toolbar, toolbars) {
index = (int)(toolbar->iconSize().height()/10)-1;
if (toolbar->objectName() != "keyToolBar")
comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar));
}
示例6: f
KoGroupButton *addViewButton(KoGroupButton::GroupPosition pos,
Kexi::ViewMode mode, QWidget *parent, const char *slot,
const QString &text, QHBoxLayout *btnLyr)
{
if (!window->supportsViewMode(mode)) {
return 0;
}
QAction *a = new KexiToggleViewModeAction(mode, q);
toggleViewModeActions.insert(mode, a);
KoGroupButton *btn = new KoGroupButton(pos, parent);
toggleViewModeButtons.insert(mode, btn);
connect(btn, SIGNAL(toggled(bool)), q, slot);
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn->setText(text);
btn->setIcon(a->icon());
QFont f(KGlobalSettings::toolBarFont());
f.setPixelSize(KexiUtils::smallFont().pixelSize());
btn->setFont(f);
btn->setToolTip(a->toolTip());
btn->setWhatsThis(a->whatsThis());
btn->setCheckable(true);
btn->setAutoRaise(true);
btnLyr->addWidget(btn);
return btn;
}
示例7: setupLocalAction
void ActionsManager::setupLocalAction(QAction *localAction, const QLatin1String &globalAction, bool connectTrigger)
{
if (!localAction)
{
return;
}
QAction *action = getAction(globalAction);
if (action)
{
localAction->setCheckable(action->isCheckable());
localAction->setChecked(action->isChecked());
localAction->setEnabled(action->isEnabled());
localAction->setIcon(action->icon());
localAction->setText(action->text());
localAction->setShortcut(action->shortcut());
localAction->setObjectName(action->objectName());
if (connectTrigger)
{
connect(localAction, SIGNAL(triggered()), action, SLOT(trigger()));
}
}
}
示例8: update
void gui_mode::update(){
/// Clear the menus
mainWindow()->modeToolbar->clear();
mainWindow()->modeMenu->clear();
/// Add the "default" mode action (modes disactivated)
mainWindow()->modeToolbar->addAction(defaultModeAction);
mainWindow()->modeMenu->addAction(defaultModeAction);
modeActionGroup->addAction(defaultModeAction);
/// Re-fill the menu with plugin names and make connections
foreach(ModePlugin* plugin, pluginManager()->modePlugins()){
if(!plugin->isApplicable()) continue;
QAction* action = plugin->action();
action->setCheckable(true);
/// Make GUI elements exclusive
modeActionGroup->addAction(action);
/// Add to menus and toolbars
mainWindow()->modeMenu->addAction(action);
if(!action->icon().isNull())
mainWindow()->modeToolbar->addAction(action);
}
/// Remember trackball is always there, thus>1
bool showtoolbar = (mainWindow()->modeToolbar->children().size() > 1);
mainWindow()->modeToolbar->setVisible(showtoolbar);
}
示例9: shouldChangePreferredValue
void PreferredLineEditWidget::shouldChangePreferredValue()
{
Akonadi::PreferredLineEditWidget w;
QAction *act = w.findChild<QAction *>(QStringLiteral("preferredaction"));
QIcon disabled = act->icon();
w.setPreferred(true);
QVERIFY(w.preferred());
QIcon enabled = act->icon();
w.setPreferred(false);
QVERIFY(!w.preferred());
QCOMPARE(act->icon(), disabled);
w.setPreferred(true);
QCOMPARE(act->icon(), enabled);
}
示例10: dir
Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* defaultAction = 0;
int defaultId = 0;
std::string path = App::Application::getResourceDir();
path += "Mod/Raytracing/Templates/";
QDir dir(QString::fromUtf8(path.c_str()), QString::fromAscii("*.lxs"));
for (unsigned int i=0; i<dir.count(); i++ ) {
QFileInfo fi(dir[i]);
QAction* a = pcAction->addAction(fi.baseName());
a->setIcon(Gui::BitmapFactory().pixmap("Raytrace_Lux"));
a->setProperty("Template", dir.absoluteFilePath(dir[i]));
}
_pcAction = pcAction;
languageChange();
if (defaultAction) {
pcAction->setIcon(defaultAction->icon());
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(pcAction->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}
return pcAction;
}
示例11: actionEvent
void TaskGroup::actionEvent (QActionEvent* e)
{
QAction *action = e->action();
switch (e->type()) {
case QEvent::ActionAdded:
{
TaskIconLabel *label = new TaskIconLabel(
action->icon(), action->text(), this);
this->addIconLabel(label);
connect(label,SIGNAL(clicked()),action,SIGNAL(triggered()));
break;
}
case QEvent::ActionChanged:
{
// update label when action changes
QBoxLayout* bl = this->groupLayout();
int index = this->actions().indexOf(action);
if (index < 0) break;
QWidgetItem* item = static_cast<QWidgetItem*>(bl->itemAt(index));
TaskIconLabel* label = static_cast<TaskIconLabel*>(item->widget());
label->setTitle(action->text());
break;
}
case QEvent::ActionRemoved:
{
// cannot change anything
break;
}
default:
break;
}
}
示例12: icon
QIcon QActionProto::icon() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->icon();
return QIcon();
}
示例13: populateList
void ToolbarEditor::populateList(QListWidget * w, QList<QAction *> actions_list, bool add_separators) {
w->clear();
QAction * action;
for (int n = 0; n < actions_list.count(); n++) {
action = static_cast<QAction*> (actions_list[n]);
if (action) {
if (!action->objectName().isEmpty()) {
QListWidgetItem * i = new QListWidgetItem;
QString text = fixname(action->text(), action->objectName());
i->setText(text + " ("+ action->objectName() +")");
QIcon icon = action->icon();
if (icon.isNull()) {
icon = Images::icon("empty_icon");
}
i->setIcon(icon);
i->setData(Qt::UserRole, action->objectName());
w->addItem(i);
}
else
if ((action->isSeparator()) && (add_separators)) {
QListWidgetItem * i = new QListWidgetItem;
//i->setText(tr("(separator)"));
i->setText("---------");
i->setData(Qt::UserRole, "separator");
i->setIcon(Images::icon("empty_icon"));
w->addItem(i);
}
}
}
}
示例14: updateToggleRunningAction
void ScServer::updateToggleRunningAction()
{
QAction *targetAction = isRunning() ? mActions[Quit] : mActions[Boot];
mActions[ToggleRunning]->setText( targetAction->text() );
mActions[ToggleRunning]->setIcon( targetAction->icon() );
mActions[ToggleRunning]->setShortcut( targetAction->shortcut() );
}
示例15: QDialog
KexiFindDialog::KexiFindDialog(QWidget* parent)
: QDialog(parent,
Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::Tool)
, d(new Private())
{
setObjectName("KexiFindDialog");
setupUi(this);
m_search->setCurrentIndex(
(int)KexiSearchAndReplaceViewInterface::Options::SearchDown);
layout()->setMargin(KDialog::marginHint());
layout()->setSpacing(KDialog::spacingHint());
QAction *a = KStandardAction::findNext(0, 0, 0);
m_btnFind->setText(a->text());
m_btnFind->setIcon(a->icon());
delete a;
m_btnClose->setText(KStandardGuiItem::close().text());
m_btnClose->setIcon(KStandardGuiItem::close().icon());
connect(m_btnFind, SIGNAL(clicked()), this, SIGNAL(findNext()));
connect(m_btnClose, SIGNAL(clicked()), this, SLOT(slotCloseClicked()));
connect(m_btnReplace, SIGNAL(clicked()), this, SIGNAL(replaceNext()));
connect(m_btnReplaceAll, SIGNAL(clicked()), this, SIGNAL(replaceAll()));
// clear message after the text is changed
connect(m_textToFind, SIGNAL(editTextChanged(QString)), this, SLOT(updateMessage(QString)));
connect(m_textToReplace, SIGNAL(editTextChanged(QString)), this, SLOT(updateMessage(QString)));
d->replaceMode = true; //to force updating by setReplaceMode()
setReplaceMode(false);
setLookInColumnList(QStringList(), QStringList());
}