本文整理汇总了C++中SymbolLayerItem::child方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolLayerItem::child方法的具体用法?C++ SymbolLayerItem::child怎么用?C++ SymbolLayerItem::child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolLayerItem
的用法示例。
在下文中一共展示了SymbolLayerItem::child方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: symbolChanged
void QgsSymbolSelectorWidget::symbolChanged()
{
SymbolLayerItem *currentItem = static_cast<SymbolLayerItem *>( model->itemFromIndex( layersTree->currentIndex() ) );
if ( !currentItem || currentItem->isLayer() )
return;
// disconnect to avoid recreating widget
disconnect( layersTree->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSymbolSelectorWidget::layerChanged );
if ( currentItem->parent() )
{
// it is a sub-symbol
QgsSymbol *symbol = currentItem->symbol();
SymbolLayerItem *parent = static_cast<SymbolLayerItem *>( currentItem->parent() );
parent->removeRow( 0 );
loadSymbol( symbol, parent );
layersTree->setCurrentIndex( parent->child( 0 )->index() );
parent->updatePreview();
}
else
{
//it is the symbol itself
loadSymbol();
QModelIndex newIndex = layersTree->model()->index( 0, 0 );
layersTree->setCurrentIndex( newIndex );
}
updatePreview();
// connect it back once things are set
connect( layersTree->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSymbolSelectorWidget::layerChanged );
}
示例2: removeLayer
void QgsSymbolSelectorWidget::removeLayer()
{
SymbolLayerItem *item = currentLayerItem();
int row = item->row();
SymbolLayerItem *parent = static_cast<SymbolLayerItem *>( item->parent() );
int layerIdx = parent->rowCount() - row - 1; // IMPORTANT
QgsSymbol *parentSymbol = parent->symbol();
QgsSymbolLayer *tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
parent->removeRow( row );
parent->updatePreview();
QModelIndex newIdx = parent->child( 0 )->index();
layersTree->setCurrentIndex( newIdx );
updateUi();
updatePreview();
//finally delete the removed layer pointer
delete tmpLayer;
}