本文整理汇总了C++中QgsVectorLayer::source方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::source方法的具体用法?C++ QgsVectorLayer::source怎么用?C++ QgsVectorLayer::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorLayer
的用法示例。
在下文中一共展示了QgsVectorLayer::source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
QgsTransaction* QgsTransaction::create( const QStringList& layerIds )
{
if ( layerIds.isEmpty() )
{
return 0;
}
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerIds.first() ) );
if ( !layer )
{
return 0;
}
QString connStr = QgsDataSourceURI( layer->source() ).connectionInfo();
QString providerKey = layer->dataProvider()->name();
QgsTransaction* ts = QgsTransaction::create( connStr, providerKey );
if ( !ts )
{
return 0;
}
Q_FOREACH ( const QString& layerId, layerIds )
{
if ( !ts->addLayer( layerId ) )
{
delete ts;
return 0;
}
}
return ts;
}
示例2: populateCbReferenceLayer
void QgsSpatialQueryDialog::populateCbReferenceLayer()
{
cbReferenceLayer->blockSignals( true );
cbReferenceLayer->clear();
// Populate new values and Set current item keeping the previous value
QString itemText;
QVariant itemData;
QIcon itemIcon;
QgsVectorLayer * lyr = NULL;
int idNew = 0;
for ( int id = 0; id < cbTargetLayer->count(); id++ )
{
itemText = cbTargetLayer->itemText( id );
itemData = cbTargetLayer->itemData( id );
itemIcon = cbTargetLayer->itemIcon( id );
lyr = static_cast<QgsVectorLayer *>( itemData.value<void *>() );
if ( lyr == mLayerTarget )
{
continue;
}
cbReferenceLayer->addItem( itemIcon, itemText, itemData );
cbReferenceLayer->setItemData( idNew, QVariant( lyr->source() ), Qt::ToolTipRole );
idNew++;
}
int idCurrent = getCbIndexLayer( false, mLayerReference );
if ( idCurrent == -1 )
{
idCurrent = 0;
}
cbReferenceLayer->setCurrentIndex( idCurrent );
cbReferenceLayer->blockSignals( false );
} // QgsSpatialQueryDialog::populateCbReferenceLayer()