本文整理汇总了C++中QAction::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setVisible方法的具体用法?C++ QAction::setVisible怎么用?C++ QAction::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processObject
void FLAccessControlMainWindow::processObject(QObject *obj)
{
QMainWindow *mw = ::qt_cast<QMainWindow *>(obj);
if (!mw || !acosPerms_)
return;
if (!perm_.isEmpty()) {
QObjectList *l = mw->queryList("QAction");
QObjectListIt ito(*l);
QAction *a;
while ((a = ::qt_cast<QAction *>(ito.current())) != 0) {
++ito;
if ((*acosPerms_)[a->name()])
continue;
if (perm_ == "-w" || perm_ == "--")
a->setVisible(false);
}
delete l;
}
QDictIterator < QString > it(*acosPerms_);
for (; it.current(); ++it) {
QAction *a = ::qt_cast<QAction *>(mw->child(it.currentKey(), "QAction"));
if (a) {
QString perm = *(*it);
if (perm == "-w" || perm == "--")
a->setVisible(false);
}
}
}
示例2: QToolBar
void tst_QToolBar::task197996_visibility()
{
QMainWindow mw;
QToolBar *toolBar = new QToolBar(&mw);
mw.addToolBar(toolBar);
toolBar->addAction(new QAction("Foo", &mw));
QAction *pAction = new QAction("Test", &mw);
toolBar->addAction(pAction);
pAction->setVisible(false);
toolBar->setVisible(false);
toolBar->setVisible(true);
pAction->setVisible(true);
mw.show();
QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
toolBar->setVisible(false);
pAction->setVisible(false);
toolBar->setVisible(true);
pAction->setVisible(true);
QTest::qWait(100);
QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
}
示例3: mainTabContextualMenu
void MainWidget::mainTabContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget_main->currentItem() == nullptr) return;
// create menu
QMenu menu(this);
QAction *refreshTable = menu.addAction(QApplication::translate("MainWidget", "Refresh"));
refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
menu.addSeparator();
QAction *startProfile = menu.addAction(QApplication::translate("MainWidget", "Start profile"));
QAction *restartProfile = menu.addAction(QApplication::translate("MainWidget", "Restart profile"));
restartProfile->setIcon(QIcon::fromTheme("view-refresh"));
QAction *enableProfile = menu.addAction(QApplication::translate("MainWidget", "Enable profile"));
menu.addSeparator();
QAction *editProfile = menu.addAction(QApplication::translate("MainWidget", "Edit profile"));
editProfile->setIcon(QIcon::fromTheme("document-edit"));
QAction *removeProfile = menu.addAction(QApplication::translate("MainWidget", "Remove profile"));
removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
restartProfile->setVisible(true);
startProfile->setText(QApplication::translate("MainWidget", "Stop profile"));
startProfile->setIcon(QIcon::fromTheme("process-stop"));
} else {
restartProfile->setVisible(false);
startProfile->setText(QApplication::translate("MainWidget", "Start profile"));
startProfile->setIcon(QIcon::fromTheme("system-run"));
}
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
enableProfile->setText(QApplication::translate("MainWidget", "Disable profile"));
enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
} else {
enableProfile->setText(QApplication::translate("MainWidget", "Enable profile"));
enableProfile->setIcon(QIcon::fromTheme("list-add"));
}
// actions
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
if (action == refreshTable) {
if (debug) qDebug() << PDEBUG << ":" << "Refresh table";
updateMainTab();
} else if (action == startProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Start profile";
mainTabStartProfile();
} else if (action == restartProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Restart profile";
mainTabRestartProfile();
} else if (action == enableProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
mainTabEnableProfile();
} else if (action == editProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Edit profile";
mainTabEditProfile();
} else if (action == removeProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Remove profile";
mainTabRemoveProfile();
}
}
示例4: actionGroupZoom
//.........这里部分代码省略.........
action = new QAction(NODE_ACTION_FISHEYE_LARGE, this);
action->setCheckable(true);
actionGroupFisheye.addAction(action);
action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this);
action->setCheckable(true);
actionGroupFisheye.addAction(action);
mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions());
mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this));
mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this));
mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this));
mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this));
mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this));
setMenuZoomEnabled(true);
setMenuSelectionToCompoundEnabled(true);
setMenuCollapseExpandEnabled(true);
setMenuExpandCompoundsEnabled(true);
setMenuFisheyeViewEnabled(true);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*)));
setLayout(mainLayout);
}
//****************************************************************************/
QtNodeEditor::~QtNodeEditor(void)
{
}
//****************************************************************************/
void QtNodeEditor::setContextMenuEnabled(bool enabled)
{
mContextMenuEnabled = enabled;
}
//****************************************************************************/
void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon)
{
mHeaderTitleIcon = fileNameIcon;
}
//****************************************************************************/
void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon)
{
mAction1Icon = fileNameIcon;
}
//****************************************************************************/
void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon)
{
mAction2Icon = fileNameIcon;
}
//****************************************************************************/
bool QtNodeEditor::isContextMenuEnabled(void)
{
return mContextMenuEnabled;
}
//****************************************************************************/
void QtNodeEditor::setMenuZoomEnabled(bool enabled)
{
mMenuZoomEnabled = enabled;
QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM);
if (action)
action->setVisible(enabled);
}
//****************************************************************************/
bool QtNodeEditor::isMenuZoomEnabled(void)
{
return mMenuZoomEnabled;
}
//****************************************************************************/
void QtNodeEditor::setMenuSelectionToCompoundEnabled(bool enabled)
{
mMenuSelectionToCompoundEnabled = enabled;
QAction* action = getActionFromContextMenu(NODE_ACTION_SELECTED_TO_COMPOUND);
if (action)
action->setVisible(enabled);
}
//****************************************************************************/
bool QtNodeEditor::isMenuSelectionToCompoundEnabled(void)
{
return mMenuSelectionToCompoundEnabled;
}
//****************************************************************************/
void QtNodeEditor::setMenuCollapseExpandEnabled(bool enabled)
{
mMenuCollapseExpandEnabled = enabled;
QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_ALL);
if (action)
action->setVisible(enabled);
action = getActionFromContextMenu(NODE_ACTION_COLLAPSE_ALL);
if (action)
action->setVisible(enabled);
}
示例5: left
Editor::Editor(QStandardItemModel *model, QWidget *parent) :
QWidget(parent), editables(Settings::fileIcons())
{
QSizePolicy left(QSizePolicy::Preferred, QSizePolicy::Preferred);
QSizePolicy right(QSizePolicy::Preferred, QSizePolicy::Preferred);
left.setHorizontalStretch(2);
right.setHorizontalStretch(4);
// -- //
QVBoxLayout *layout = new QVBoxLayout(this);
QToolBar *tool_bar = new QToolBar(this);
files = new QComboBox(tool_bar);
tabs = new QTabWidget(this);
tabs->setTabsClosable(true);
this->variants = new QComboBox(tool_bar);
files->setModel(model);
files->setStyleSheet(STYLESHEET_COMBOBOXES);
files->setSizePolicy(left);
layout->addWidget(tool_bar);
layout->addWidget(tabs);
layout->setContentsMargins(0, 1, 0, 2);
layout->setSpacing(2);
tool_bar->addWidget(files);
tool_bar->layout()->setContentsMargins(0, 0, 0, 0);
tool_bar->layout()->setSpacing(2);
this->variants->setStyleSheet(STYLESHEET_COMBOBOXES);
this->variants->setSizePolicy(right);
QAction *variants = tool_bar->addWidget(this->variants);
variants->setVisible(false);
setLayout(layout);
setMinimumSize(64, 64);
connections.append(connect(tabs, static_cast<void(QTabWidget::*)(int)>(&QTabWidget::tabCloseRequested), [ this ] (int index) {
this->files->removeItem(index);
this->tabs->removeTab(index);
}));
connections.append(connect(tabs, static_cast<void(QTabWidget::*)(int)>(&QTabWidget::currentChanged), [ this ] (int index) {
if (index < 0)
return;
this->files->setCurrentIndex(index);
}));
connections.append(connect(files, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [ variants, this ] (int index) {
if (index < 0)
return;
this->tabs->setCurrentIndex(index);
emit selectionChanged(index);
QWidget *widget = this->tabs->currentWidget();
if (!widget)
return;
if (widget->inherits(Viewer::staticMetaObject.className()))
variants->setVisible(true);
else
variants->setVisible(false);
widget->setFocus();
}));
}
示例6: loadRecentFiles
void MainWindow::loadRecentFiles(QSettings *s)
{
QStringList files;
bool modified = false;
s->beginGroup("Recent_Files");
for (int c = 1; c <= 4; c++) {
QString key = QString("File_%1").arg(c);
if (s->contains(key)) {
QString file = s->value(key).toString();
if (QFile::exists(file)) {
files.append(file);
} else {
modified = true;
}
} else {
break;
}
}
if (modified) {
for (int c = 0; c < 4; c++) {
QString key = QString("File_%1").arg(c + 1);
if (files.count() > c) {
s->setValue(key, files.at(c));
} else {
if (s->contains(key)) {
s->remove(key);
}
}
}
s->sync();
}
s->endGroup();
for (int c = 0; c < 4; c++) {
QAction *action = this->findChild<QAction *>(QString("actionRecent%1").arg(c + 1));
if (files.count() > c) {
QFileInfo fi(files.at(c));
action->setText(fi.fileName());
action->setToolTip(fi.absoluteFilePath());
action->setVisible(true);
} else {
action->setVisible(false);
}
}
}
示例7: QActionGroup
PreviewActionGroup::PreviewActionGroup(QDesignerFormEditorInterface *core, QObject *parent) :
QActionGroup(parent),
m_core(core)
{
/* Create a list of up to MaxDeviceActions invisible actions to be
* populated with device profiles (actiondata: index) followed by the
* standard style actions (actiondata: style name). */
connect(this, SIGNAL(triggered(QAction*)), this, SLOT(slotTriggered(QAction*)));
setExclusive(true);
const QString objNamePostfix = QStringLiteral("_action");
// Create invisible actions for devices. Set index as action data.
QString objNamePrefix = QStringLiteral("__qt_designer_device_");
for (int i = 0; i < MaxDeviceActions; i++) {
QAction *a = new QAction(this);
QString objName = objNamePrefix;
objName += QString::number(i);
objName += objNamePostfix;
a->setObjectName(objName);
a->setVisible(false);
a->setData(i);
addAction(a);
}
// Create separator at index MaxDeviceActions
QAction *sep = new QAction(this);
sep->setObjectName(QStringLiteral("__qt_designer_deviceseparator"));
sep->setSeparator(true);
sep->setVisible(false);
addAction(sep);
// Populate devices
updateDeviceProfiles();
// Add style actions
const QStringList styles = QStyleFactory::keys();
const QStringList::const_iterator cend = styles.constEnd();
// Make sure ObjectName is unique in case toolbar solution is used.
objNamePrefix = QStringLiteral("__qt_designer_style_");
// Create styles. Set style name string as action data.
for (QStringList::const_iterator it = styles.constBegin(); it != cend ;++it) {
QAction *a = new QAction(tr("%1 Style").arg(*it), this);
QString objName = objNamePrefix;
objName += *it;
objName += objNamePostfix;
a->setObjectName(objName);
a->setData(*it);
addAction(a);
}
}
示例8: AppletToolbarBase
Context::AppletToolbarAppletItem::AppletToolbarAppletItem( QGraphicsItem* parent, Plasma::Applet* applet )
: AppletToolbarBase( parent )
, m_applet( applet )
, m_label( 0 )
, m_deleteIcon( 0 )
, m_labelPadding( 5 )
, m_configEnabled( false )
{
m_label = new QGraphicsTextItem( this );
if( m_applet )
{
m_label->setPlainText( m_applet->name() );
setToolTip( m_applet->name() );
}
else
{
m_label->setPlainText( i18n("no applet name") );
}
setAcceptHoverEvents( true );
m_label->setAcceptHoverEvents( true );
QAction* delApplet = new QAction( i18n( "Remove Applet" ), this );
delApplet->setIcon( KIcon( "edit-delete" ) );
delApplet->setVisible( true );
delApplet->setEnabled( true );
connect( delApplet, SIGNAL( triggered() ), this, SLOT( deleteApplet() ) );
m_deleteIcon = addAction( delApplet, 18 );
m_deleteIcon->hide();
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
paletteChanged( palette() );
connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) );
}
示例9: build_recent_files_menu
void MainWindow::build_recent_files_menu()
{
assert(m_recently_opened.empty());
m_recently_opened.reserve(MaxRecentlyOpenedFiles);
for (int i = 0; i < MaxRecentlyOpenedFiles; ++i)
{
QAction* action = new QAction(this);
action->setVisible(false);
connect(action, SIGNAL(triggered()), SLOT(slot_open_recent()));
m_ui->menu_open_recent->addAction(action);
m_recently_opened.push_back(action);
}
QSettings settings(SettingsOrgString, SettingsRecentFilesEntryString);
QStringList files = settings.value(SettingsRecentFileListString).toStringList();
update_recent_files_menu(files);
m_ui->menu_open_recent->addSeparator();
m_clear_open_recent_menu = new QAction(this);
m_clear_open_recent_menu->setText("&Clear Menu");
connect(m_clear_open_recent_menu, SIGNAL(triggered()), SLOT(slot_clear_open_recent_files_menu()));
m_ui->menu_open_recent->addAction(m_clear_open_recent_menu);
}
示例10: setToolbarItemState
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
QAction *action = myToolbarActions[item];
if (action != 0) {
action->setEnabled(enabled);
action->setVisible(visible);
}
}
示例11: setToolbarItemState
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
QAction *action = myActions[&*item];
if (action != 0) {
action->setEnabled(enabled);
action->setVisible(visible);
}
switch (item->type()) {
default:
break;
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
shared_ptr<ZLPopupData> data = buttonItem.popupData();
if (!data.isNull() && (data->id() != myPopupIdMap[&buttonItem])) {
myPopupIdMap[&buttonItem] = data->id();
QToolButton *button = myMenuButtons[&buttonItem];
QMenu *menu = button->menu();
menu->clear();
const size_t count = data->count();
for (size_t i = 0; i < count; ++i) {
menu->addAction(new ZLQtRunPopupAction(menu, data, i));
}
}
break;
}
}
}
示例12: KSystemTrayIcon
DockWidget::DockWidget(QWidget *parent, const char *name, PPPStats *st)
: KSystemTrayIcon(parent), stats(st) {
setObjectName(name);
// load pixmaps
dock_none_pixmap = UserIcon("dock_none");
dock_left_pixmap = UserIcon("dock_left");
dock_right_pixmap = UserIcon("dock_right");
dock_both_pixmap = UserIcon("dock_both");
setIcon(dock_none_pixmap);
// popup menu for right mouse button
popup_m = contextMenu();
popup_m->addAction(i18n("Details"), p_kppp, SLOT(showStats()));
popup_m->addSeparator();
popup_m->addAction(i18n("Disconnect"), p_kppp, SLOT(disconnect()));
// TODO see if we can rather connect the quit action to the
// main window's quit handling, bypassing KSystemTrayIcon::maybeQuit
QAction *quit =
actionCollection()->action(KStandardAction::name(KStandardAction::Quit));
if (quit != 0)
quit->setVisible(false);
// connect to stats for little modem animation
connect(stats, SIGNAL(statsChanged(int)), SLOT(paintIcon(int)));
DockWidget::dock_widget = this;
}
示例13: itemInserted
QAction *ToolBarChanger::insertWidget(QWidget *AWidget, int AGroup)
{
if (!FWidgets.values().contains(AWidget))
{
if (AGroup > TBG_ALLIGN_CHANGE)
FAllignChange->setVisible(true);
QMap<int, QAction *>::const_iterator it = FSeparators.upperBound(AGroup);
QAction *before = it!=FSeparators.end() ? it.value() : NULL;
QAction *handle = before!=NULL ? FToolBar->insertWidget(before, AWidget) : FToolBar->addWidget(AWidget);
if (!FSeparators.contains(AGroup))
{
QAction *separator = FToolBar->insertSeparator(handle);
separator->setVisible(FSeparatorsVisible);
FSeparators.insert(AGroup, separator);
updateSeparatorVisible();
}
FWidgets.insertMulti(AGroup,AWidget);
FHandles.insert(AWidget, handle);
connect(AWidget,SIGNAL(destroyed(QObject *)),SLOT(onWidgetDestroyed(QObject *)));
emit itemInserted(before,handle,FButtons.key(qobject_cast<QToolButton *>(AWidget)),AWidget,AGroup);
updateVisible();
}
return FHandles.value(AWidget);
}
示例14: AppletToolbarBase
Context::AppletToolbarConfigItem::AppletToolbarConfigItem( QGraphicsItem* parent )
: AppletToolbarBase( parent )
, m_iconPadding( 2 )
, m_icon( 0 )
{
QAction* listAdd = new QAction( i18n( "Configure Applets..." ), this );
listAdd->setIcon( KIcon( "configure" ) );
listAdd->setVisible( true );
listAdd->setEnabled( true );
connect( listAdd, SIGNAL(triggered()), this, SIGNAL(triggered()) );
m_icon = new Plasma::IconWidget( this );
m_icon->setAction( listAdd );
m_icon->setText( QString() );
m_icon->setToolTip( listAdd->text() );
m_icon->setDrawBackground( false );
m_icon->setOrientation( Qt::Horizontal );
QSizeF iconSize = m_icon->sizeFromIconSize( 22 );
m_icon->setMinimumSize( iconSize );
m_icon->setMaximumSize( iconSize );
m_icon->resize( iconSize );
m_icon->setZValue( zValue() + 1 );
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
}
示例15: QWebView
HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent)
: QWebView(parent)
, helpEngine(engine)
, parentWidget(parent)
, loadFinished(false)
{
setAcceptDrops(false);
setPage(new HelpPage(parent, helpEngine, this));
page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
action->setText(tr("Open Link in New Tab"));
if (!parent)
action->setVisible(false);
pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
}