本文整理汇总了C++中QAction::objectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::objectName方法的具体用法?C++ QAction::objectName怎么用?C++ QAction::objectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::objectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotPopulateToolbar
//adds dynamic actions to the toolbar (example settings)
void RenderWindow::slotPopulateToolbar(bool completeRefresh)
{
WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) started");
QDir toolbarDir = QDir(systemData.dataDirectory + "toolbar");
toolbarDir.setSorting(QDir::Time);
QStringList toolbarFiles = toolbarDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
QSignalMapper *mapPresetsFromExamplesLoad = new QSignalMapper(this);
QSignalMapper *mapPresetsFromExamplesRemove = new QSignalMapper(this);
ui->toolBar->setIconSize(QSize(gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size")));
QList<QAction *> actions = ui->toolBar->actions();
QStringList toolbarInActions;
for (int i = 0; i < actions.size(); i++)
{
QAction * action = actions.at(i);
if(action->objectName() == "actionAdd_Settings_to_Toolbar") continue;
if(!toolbarFiles.contains(action->objectName()) || completeRefresh)
{
// preset has been removed
ui->toolBar->removeAction(action);
}
else
{
toolbarInActions << action->objectName();
}
}
for (int i = 0; i < toolbarFiles.size(); i++)
{
if(toolbarInActions.contains(toolbarFiles.at(i)))
{
// already present
continue;
}
QString filename = systemData.dataDirectory + "toolbar/" + toolbarFiles.at(i);
cThumbnailWidget *thumbWidget = NULL;
if (QFileInfo(filename).suffix() == QString("fract"))
{
WriteLogString("Generating thumbnail for preset", filename);
cSettings parSettings(cSettings::formatFullText);
parSettings.BeQuiet(true);
if (parSettings.LoadFromFile(filename))
{
cParameterContainer *par = new cParameterContainer;
cFractalContainer *parFractal = new cFractalContainer;
InitParams(par);
for (int i = 0; i < NUMBER_OF_FRACTALS; i++)
InitFractalParams(&parFractal->at(i));
if (parSettings.Decode(par, parFractal))
{
thumbWidget = new cThumbnailWidget(gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"), 2, this);
thumbWidget->UseOneCPUCore(true);
thumbWidget->AssignParameters(*par, *parFractal);
}
delete par;
delete parFractal;
}
}
if(thumbWidget)
{
QWidgetAction *action = new QWidgetAction(this);
QToolButton *buttonLoad = new QToolButton;
QVBoxLayout *tooltipLayout = new QVBoxLayout;
QToolButton *buttonRemove = new QToolButton;
tooltipLayout->setContentsMargins(3, 3, 3, 3);
tooltipLayout->addWidget(thumbWidget);
QIcon iconDelete = QIcon::fromTheme("list-remove", QIcon(":system/icons/list-remove.svg"));
buttonRemove->setIcon(iconDelete);
buttonRemove->setMaximumSize(QSize(15, 15));
buttonRemove->setStyleSheet("margin-bottom: -2px; margin-left: -2px;");
tooltipLayout->addWidget(buttonRemove);
buttonLoad->setToolTip(QObject::tr("Toolbar settings: ") + filename);
buttonLoad->setLayout(tooltipLayout);
action->setDefaultWidget(buttonLoad);
action->setObjectName(toolbarFiles.at(i));
ui->toolBar->addAction(action);
mapPresetsFromExamplesLoad->setMapping(buttonLoad, filename);
mapPresetsFromExamplesRemove->setMapping(buttonRemove, filename);
QApplication::connect(buttonLoad, SIGNAL(clicked()), mapPresetsFromExamplesLoad, SLOT(map()));
QApplication::connect(buttonRemove, SIGNAL(clicked()), mapPresetsFromExamplesRemove, SLOT(map()));
}
}
QApplication::connect(mapPresetsFromExamplesLoad,
SIGNAL(mapped(QString)),
this,
SLOT(slotMenuLoadPreset(QString)));
QApplication::connect(mapPresetsFromExamplesRemove,
SIGNAL(mapped(QString)),
this,
SLOT(slotMenuRemovePreset(QString)));
WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) finished");
}
示例2: switchWidget
bool QgsCustomizationDialog::switchWidget( QWidget *widget, QMouseEvent *e )
{
Q_UNUSED( e );
QgsDebugMsg( "Entered" );
if ( !actionCatch->isChecked() )
return false;
QString path = widgetPath( widget );
QgsDebugMsg( "path = " + path );
if ( path.startsWith( "/QgsCustomizationDialogBase" ) )
{
// do not allow modification of this dialog
return false;
}
else if ( path.startsWith( "/QgisApp" ) )
{
// changes to main window
// (work with toolbars, tool buttons)
if ( widget->inherits( "QToolBar" ) )
{
path = "/Toolbars/" + widget->objectName();
}
else if ( widget->inherits( "QToolButton" ) )
{
QToolButton* toolbutton = qobject_cast<QToolButton*>( widget );
QAction* action = toolbutton->defaultAction();
if ( !action )
return false;
QString toolbarName = widget->parent()->objectName();
QString actionName = action->objectName();
path = "/Toolbars/" + toolbarName + "/" + actionName;
}
else
{
// unsupported widget in main window
return false;
}
}
else
{
// ordinary widget in a dialog
path = "/Widgets" + path;
}
QgsDebugMsg( "path final = " + path );
bool on = !itemChecked( path );
QgsDebugMsg( QString( "on = %1" ).arg( on ) );
setItemChecked( path, on );
QTreeWidgetItem *myItem = item( path );
if ( myItem )
{
treeWidget->scrollToItem( myItem, QAbstractItemView::PositionAtCenter );
treeWidget->clearSelection();
myItem->setSelected( true );
QString style;
if ( !on )
{
style = "background-color: #FFCCCC;";
}
widget->setStyleSheet( style );
}
return true;
}