本文整理汇总了C++中QAction::setIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setIcon方法的具体用法?C++ QAction::setIcon怎么用?C++ QAction::setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contextMenuEvent
void MusicSongsListWidget::contextMenuEvent(QContextMenuEvent *event)
{
QTableWidget::contextMenuEvent(event);
QMenu rightClickMenu(this);
QMenu musicPlaybackMode(tr("playbackMode"), &rightClickMenu);
rightClickMenu.setStyleSheet(MusicUIObject::MMenuStyle02);
rightClickMenu.addAction(tr("changSongName"), this, SLOT(setChangSongName()));
rightClickMenu.addAction(QIcon(":/contextMenu/play"), tr("musicPlay"), this, SLOT(musicPlayClicked()));
rightClickMenu.addMenu(&musicPlaybackMode);
QAction *order = musicPlaybackMode.addAction(tr("OrderPlay"), this, SIGNAL(musicPlayOrder()));
QAction *random = musicPlaybackMode.addAction(tr("RandomPlay"), this, SIGNAL(musicPlayRandom()));
QAction *lCycle = musicPlaybackMode.addAction(tr("ListCycle"), this, SIGNAL(musicPlayListLoop()));
QAction *sCycle = musicPlaybackMode.addAction(tr("SingleCycle"), this, SIGNAL(musicPlayOneLoop()));
QAction *once = musicPlaybackMode.addAction(tr("PlayOnce"), this, SIGNAL(musicPlayItemOnce()));
(m_songplaymode == MusicObject::MC_PlayOrder) ? order->setIcon(QIcon(":/share/selected")) : order->setIcon(QIcon());
(m_songplaymode == MusicObject::MC_PlayRandom) ? random->setIcon(QIcon(":/share/selected")) : random->setIcon(QIcon());
(m_songplaymode == MusicObject::MC_PlayListLoop) ? lCycle->setIcon(QIcon(":/share/selected")) : lCycle->setIcon(QIcon());
(m_songplaymode == MusicObject::MC_PlayOneLoop) ? sCycle->setIcon(QIcon(":/share/selected")) : sCycle->setIcon(QIcon());
(m_songplaymode == MusicObject::MC_PlayOnce) ? once->setIcon(QIcon(":/share/selected")) : once->setIcon(QIcon());
rightClickMenu.addSeparator();
rightClickMenu.addAction(QIcon(":/contextMenu/love"), tr("addToLove"), this, SLOT(addMusicSongToLovestListAt()));
QMenu musicAddNewFiles(tr("addNewFiles"), &rightClickMenu);
rightClickMenu.addMenu(&musicAddNewFiles)->setIcon(QIcon(":/contextMenu/add"));
musicAddNewFiles.addAction(tr("openOnlyFiles"), this, SIGNAL(musicAddNewFiles()));
musicAddNewFiles.addAction(tr("openOnlyDir"), this, SIGNAL(musicAddNewDir()));
QMenu musicToolMenu(tr("musicTool"), &rightClickMenu);
musicToolMenu.addAction(tr("bell"), this, SLOT(musicMakeRingWidget()));
musicToolMenu.addAction(tr("transform"), this, SLOT(musicTransformWidget()));
rightClickMenu.addMenu(&musicToolMenu);
rightClickMenu.addAction(tr("musicInfoD"), this, SLOT(musicFileInformation()));
rightClickMenu.addAction(tr("openFileDir"), this, SLOT(musicOpenFileDir()));
rightClickMenu.addSeparator();
rightClickMenu.addAction(QIcon(":/contextMenu/delete"), tr("delete"), this, SLOT(setDeleteItemAt()));
rightClickMenu.addAction(tr("deleteWithFile"), this, SLOT(setDeleteItemWithFile()));
rightClickMenu.addAction(tr("deleteAll"), this, SLOT(setDeleteItemAll()));
rightClickMenu.exec(QCursor::pos());
//Menu location for the current mouse position
event->accept();
}
示例2: init
void Albums::init()
{
DEBUG_BLOCK
// Call the base implementation.
Context::Applet::init();
enableHeader( true );
setHeaderText( i18n( "Recently Added Albums" ) );
setCollapseOffHeight( -1 );
setCollapseHeight( m_header->height() );
setMinimumHeight( collapseHeight() );
QAction *settingsAction = new QAction( this );
settingsAction->setIcon( KIcon( "preferences-system" ) );
settingsAction->setEnabled( true );
settingsAction->setToolTip( i18n( "Settings" ) );
addRightHeaderAction( settingsAction );
connect( settingsAction, SIGNAL(triggered()), this, SLOT(showConfigurationInterface()) );
QAction *filterAction = new QAction( this );
filterAction->setIcon( KIcon( "view-filter" ) );
filterAction->setEnabled( true );
filterAction->setToolTip( i18n( "Filter Albums" ) );
m_filterIcon = addLeftHeaderAction( filterAction );
connect( filterAction, SIGNAL(triggered()), this, SLOT(showFilterBar()) );
m_albumsView = new AlbumsView( this );
m_albumsView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
if( m_rightAlignLength )
m_albumsView->setLengthAlignment( Qt::AlignRight );
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical );
layout->addItem( m_header );
layout->addItem( m_albumsView );
setLayout( layout );
dataEngine( "amarok-current" )->connectSource( "albums", this );
connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)),
this, SLOT(collectionDataChanged(Collections::Collection*)) );
updateConstraints();
}
示例3: font
LogWidget::LogWidget(QWidget *parent)
: QMainWindow(parent) {
m_contents = new QTextEdit(this);
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
m_contents->setFont(font);
m_contents->setReadOnly(true);
QPalette palette;
palette.setColor(QPalette::Base, Qt::black);
m_contents->setPalette(palette);
setPalette(palette);
QToolBar *toolBar = new QToolBar(this);
toolBar->setMovable(false);
toolBar->setAllowedAreas(Qt::TopToolBarArea);
toolBar->setIconSize(QSize(32, 32));
toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
toolBar->setFloatable(false);
QAction *actionShowStats = new QAction(this);
QIcon showStatsIcon;
showStatsIcon.addFile(QString::fromUtf8(":/resources/showStats.png"), QSize(), QIcon::Normal, QIcon::Off);
actionShowStats->setIcon(showStatsIcon);
actionShowStats->setToolTip(tr("Show statistics"));
actionShowStats->setText(tr("Show Statistics"));
connect(actionShowStats, SIGNAL(triggered()), this, SLOT(onShowStats()));
toolBar->addAction(actionShowStats);
QAction *actionClear = new QAction(this);
QIcon clearIcon;
clearIcon.addFile(QString::fromUtf8(":/resources/clear.png"), QSize(), QIcon::Normal, QIcon::Off);
actionClear->setIcon(clearIcon);
actionClear->setToolTip(tr("Clear"));
actionClear->setText(tr("Clear"));
connect(actionClear, SIGNAL(triggered()), m_contents, SLOT(clear()));
toolBar->addAction(actionClear);
#if defined(__OSX__)
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
#endif
addToolBar(Qt::TopToolBarArea, toolBar);
setCentralWidget(m_contents);
setUnifiedTitleAndToolBarOnMac(true);
setWindowTitle(tr("Log"));
resize(QSize(1000, 500));
}
示例4: createAction
/**
* Create an action for an entry in the context menu.
* @param text the text of the action
* @param method the method to call when triggered
* @param icon the shown icon
* @return the created action
*/
QAction* RefactoringAssistant::createAction(const QString& text, const char * method, const Icon_Utils::IconType icon)
{
Q_UNUSED(method);
QAction* action = new QAction(this);
action->setText(text);
if (icon != Icon_Utils::N_ICONTYPES) {
action->setIcon(Icon_Utils::SmallIcon(icon));
}
return action;
}
示例5: createGUIAction
QAction* RS_ActionBlocksFreezeAll::createGUIAction(RS2::ActionType type, QObject* /*parent*/) {
QAction* action = NULL;
if (type==RS2::ActionBlocksFreezeAll) {
// tr("Freeze all")
action= new QAction(tr("&Hide all"), NULL);
//action->zetStatusTip(tr("Freeze all blocks"));
action->setIcon(QIcon(":/ui/blockfreeze.png"));
}
else if (type==RS2::ActionBlocksDefreezeAll) {
// tr("&Defreeze all")
action = new QAction(tr("&Show all"), NULL);
//action->zetStatusTip(tr("Defreeze all blocks"));
action->setIcon(QIcon(":/ui/blockdefreeze.png"));
}
return action;
}
示例6: onItemContextMenu
void SelectionView::onItemContextMenu(QPoint point)
{
QListWidgetItem *item = selectionView->itemAt(point);
if (!item)
return;
QMenu *menu = new QMenu;
QAction *selectAction = menu->addAction(tr("Select only"),this,SLOT(select()));
selectAction->setIcon(QIcon(QString::fromAscii(":/icons/view-select.svg")));
selectAction->setToolTip(tr("Selects only this object"));
QAction *deselectAction = menu->addAction(tr("Deselect"),this,SLOT(deselect()));
deselectAction->setIcon(QIcon(QString::fromAscii(":/icons/view-unselectable.svg")));
deselectAction->setToolTip(tr("Deselects this object"));
QAction *zoomAction = menu->addAction(tr("Zoom fit"),this,SLOT(zoom()));
zoomAction->setIcon(QIcon(QString::fromAscii(":/icons/view-zoom-fit.svg")));
zoomAction->setToolTip(tr("Selects and fits this object in the 3D window"));
QAction *gotoAction = menu->addAction(tr("Go to selection"),this,SLOT(treeSelect()));
gotoAction->setToolTip(tr("Selects and locates this object in the tree view"));
menu->exec(selectionView->mapToGlobal(point));
}
示例7: contextMenuEvent
void AWebView::contextMenuEvent (QContextMenuEvent* event)
{
QString selected = page()->selectedText();
if (selected.length() == 0 || LinkHovered == true)
QWebView::contextMenuEvent(event);
else
{
// Странно, но если делать m_menu переменной класса и задать все нужные свойства в конструкторе,
// то возникает AV :\ разбираться с причинами лениво, ибо не так уж и накладно создавать каждый раз
QMenu* m_menu = new QMenu(this);
m_menu->addAction(pageAction(QWebPage::Copy));
m_menu->addSeparator();
QAction* yandex = m_menu->addAction(QString::fromUtf8("Яндекс"));
yandex->setIcon(QIcon(":/icons/yandex.ico"));
QAction* wikipedia = m_menu->addAction(QString::fromUtf8("Википедия"));
wikipedia->setIcon(QIcon(":/icons/wikipedia.ico"));
QAction* google = m_menu->addAction(QString::fromUtf8("Google"));
google->setIcon(QIcon(":/icons/google.ico"));
QAction* google_translate = m_menu->addAction(QString::fromUtf8("Google Переводчик"));
google_translate->setIcon(QIcon(":/icons/google.translate.ico"));
QAction* rsdn = m_menu->addAction(QString::fromUtf8("RSDN"));
rsdn->setIcon(QIcon(":/icons/rsdn16.png"));
connect(yandex, SIGNAL(triggered()), this, SLOT(menu_yandex_triggered()));
connect(wikipedia, SIGNAL(triggered()), this, SLOT(menu_wikipedia_triggered()));
connect(google, SIGNAL(triggered()), this, SLOT(menu_google_triggered()));
connect(google_translate, SIGNAL(triggered()), this, SLOT(menu_google_translate_triggered()));
connect(rsdn, SIGNAL(triggered()), this, SLOT(menu_rsdn_triggered()));
m_menu->exec(event->globalPos());
delete m_menu;
}
}
示例8: add_menu_items
void LayerGeoref::add_menu_items(QMenu & menu)
{
QAction * action = NULL;
action = new QAction(QObject::tr("&Zoom to Fit Map"), this);
action->setIcon(QIcon::fromTheme("GTK_STOCK_ZOOM_FIT"));
QObject::connect(action, SIGNAL (triggered(bool)), this, SLOT (zoom_to_fit_cb(void)));
menu.addAction(action);
action = new QAction(QObject::tr("&Goto Map Center"), this);
action->setIcon(QIcon::fromTheme("GTK_STOCK_JUMP_TO"));
QObject::connect(action, SIGNAL (triggered(bool)), this, SLOT (goto_center_cb(void)));
menu.addAction(action);
action = new QAction(QObject::tr("&Export to World File"), this);
action->setIcon(QIcon::fromTheme("GTK_STOCK_HARDDISK"));
QObject::connect(action, SIGNAL (triggered(bool)), this, SLOT (export_params_cb(void)));
menu.addAction(action);
}
示例9: createGUIAction
QAction* RS_ActionInfoAngle::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/) {
/* RVT_PORT QAction* action = new QAction(tr("Angle between two lines"),
tr("&Angle between two lines"),
QKeySequence(), NULL); */
QAction* action = new QAction(tr("An&gle between two lines"), NULL);
//action->zetStatusTip(tr("Measures the angle between two lines"));
action->setIcon(QIcon(":/extui/infoangle.png"));
return action;
}
示例10: slotTabContextMenuRequest
void Pane::slotTabContextMenuRequest( QWidget * tab, const QPoint &pos )
{
if ( !tab )
return; // sanity
KMenu menu( this );
if ( !tab->inherits( "KMail::MessageListView::Widget" ) )
return;
Widget * w = dynamic_cast< Widget * >( tab );
if ( !w )
return; // sanity
QVariant data;
data.setValue< void * >( static_cast< void * >( w ) );
QAction * act;
act = menu.addAction( i18nc( "@action:inmenu", "Close Tab" ) );
act->setData( data );
act->setEnabled( count() > 1 );
act->setIcon( SmallIcon( "tab-close" ) );
QObject::connect(
act, SIGNAL( triggered( bool ) ),
SLOT( slotActionTabCloseRequest() )
);
act = menu.addAction( i18nc("@action:inmenu", "Close All Other Tabs" ) );
act->setData( data );
act->setEnabled( count() > 1 );
act->setIcon( SmallIcon( "tab-close-other" ) );
QObject::connect(
act, SIGNAL( triggered( bool ) ),
SLOT( slotActionTabCloseAllButThis() )
);
if ( menu.isEmpty() )
return; // nuthin to show
menu.exec( pos );
}
示例11: createGUIAction
QAction* RS_ActionDrawCircle::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/) {
/*RVT_PORT QAction* action = new QAction(tr("Circle: Center, Point"),
tr("Center, &Point"),
QKeySequence(), NULL); */
// "Circle: Center, Point"
QAction* action = new QAction(tr("Center, &Point"), NULL);
action->setIcon(QIcon(":/extui/circles.png"));
//action->zetStatusTip(tr("Draw circles with center and point"));
return action;
}
示例12: display
void WindowService::display(GenericInterface* gi)
{
_mdi = gi->initCentralWidget();
_mdi->setActivationOrder(QMdiArea::CreationOrder);
_nav = new NavigationDock(tr("Images"), gi);
gi->addDockWidget(_navPos, _nav);
QAction* tile = gi->menu(tr("&Window"))->addAction(tr("&Tile windows"));
tile->setIcon(QIcon(":/images/application-view-tile.png"));
//tile->setShortcut(QKeySequence::Open);
gi->toolBar(tr("Tools"))->addAction(tile);
QObject::connect(tile, SIGNAL(triggered()), _mdi, SLOT(tileSubWindows()));
QAction* cascade = gi->menu(tr("&Window"))->addAction(tr("&Cascade windows"));
cascade->setIcon(QIcon(":/images/application-cascade.png"));
//tile->setShortcut(QKeySequence::Open);
gi->toolBar(tr("Tools"))->addAction(cascade);
QObject::connect(cascade, SIGNAL(triggered()), _mdi, SLOT(cascadeSubWindows()));
}
示例13: addStatus
void StatusMenu::addStatus(XMPP::Status::Type type)
{
QAction* action = new QAction(status2txt(type), this);
action->setCheckable(true);
action->setChecked(currentStatus_ == type);
action->setIcon(PsiIconset::instance()->status(type).icon());
action->setProperty("type", QVariant(type));
connect(action, SIGNAL(triggered()), SLOT(actionActivated()));
addAction(action);
}
示例14: initCapabilityMenu
void ConsoleChannel::initCapabilityMenu(const QLCChannel* ch)
{
QLCCapability* cap;
QMenu* valueMenu;
QAction* action;
QString s;
QString t;
QListIterator <QLCCapability*> it(ch->capabilities());
while (it.hasNext() == true)
{
cap = it.next();
// Set the value range and name as the menu item's name
s = QString("%1: %2 - %3").arg(cap->name())
.arg(cap->min()).arg(cap->max());
if (cap->max() - cap->min() > 0)
{
// Create submenu for ranges of more than one value
valueMenu = new QMenu(m_menu);
valueMenu->setTitle(s);
/* Add a color icon */
if (ch->group() == QLCChannel::Colour)
valueMenu->setIcon(colorIcon(cap->name()));
for (int i = cap->min(); i <= cap->max(); i++)
{
action = valueMenu->addAction(
t.sprintf("%.3d", i));
action->setData(i);
}
m_menu->addMenu(valueMenu);
}
else
{
// Just one value in this range, put that into the menu
action = m_menu->addAction(s);
action->setData(cap->min());
/* Add a color icon */
if (ch->group() == QLCChannel::Colour)
action->setIcon(colorIcon(cap->name()));
}
}
// Connect menu item activation signal to this
connect(m_menu, SIGNAL(triggered(QAction*)),
this, SLOT(slotContextMenuTriggered(QAction*)));
// Set the menu also as the preset button's popup menu
m_presetButton->setMenu(m_menu);
}
示例15: loadCategories
// Most initialization is moved from constructor to allow signals triggered correctly
void ClipartCategoriesList::loadCategories()
{
TimeMeasure t("ClipartCategoriesList::loadCategories()");
// Fetch list of clipart subfolders
QString baseClipartFolder = AppTools::getClipartResourcesFolder();
QDir clipartFolder(baseClipartFolder);
if (!clipartFolder.exists()) // If clipart folder not exists (e.g. on development computers) we try to find clipart directly in "Clipart"
{
baseClipartFolder = CLIPART_DIR;
#ifdef Q_WS_MAC
baseClipartFolder = "../../" + baseClipartFolder;
#endif
clipartFolder = QDir(baseClipartFolder);
}
QStringList folders = clipartFolder.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
// Add a button with action for each subfolder
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
for (int i = 0; i < folders.size(); i++)
{
QAction *action = new QAction(this);
action->setToolTip(folders[i]);
QString categoryFolder = AppTools::addPathSeparator(baseClipartFolder) + folders[i];
QString iconFile = categoryFolder + CLIPART_ICON_EXTENSION;
QIcon icon(iconFile);
action->setIcon(icon);
QToolButton *button = new QToolButton(this);
button->setDefaultAction(action);
button->setCheckable(true);
connect(button, SIGNAL(triggered(QAction *)), this, SLOT(on_toolbutton_triggered(QAction *)));
layout->addWidget(button);
buttons << button;
clipartCategories[action] = getClipartFolder(categoryFolder, action);
if (!startAction) startAction = action;
}
layout->addStretch();
this->setLayout(layout);
if (startAction)
sendClipartLoadRequest(startAction);
}