[QGIS-Developer] pyqgis - layer.saveDefaultStyle() for PostGIS layers
Luigi Pirelli
luipir at gmail.com
Mon Sep 25 05:48:14 PDT 2017
from the code:
mLayer->saveStyleToDatabase and mLayer->saveDefaultStyle
and in
QString QgsMapLayer::saveDefaultStyle( bool & theResultFlag )
{
return saveNamedStyle( styleURI(), theResultFlag );
}
=> seems you are doing correct.
any log message?
******************************************
void QgsVectorLayerProperties::saveDefaultStyle_clicked()
{
apply();
QString errorMsg;
if ( mLayer->dataProvider()->isSaveAndLoadStyleToDBSupported() )
{
QMessageBox askToUser;
askToUser.setText( tr( "Save default style to: " ) );
askToUser.setIcon( QMessageBox::Question );
askToUser.addButton( tr( "Cancel" ), QMessageBox::RejectRole );
askToUser.addButton( tr( "Local database" ), QMessageBox::NoRole );
askToUser.addButton( tr( "Datasource database" ), QMessageBox::YesRole );
switch ( askToUser.exec() )
{
case 0:
return;
case 2:
mLayer->saveStyleToDatabase( "", "", true, "", errorMsg );
if ( errorMsg.isNull() )
{
return;
}
break;
default:
break;
}
}
bool defaultSavedFlag = false;
errorMsg = mLayer->saveDefaultStyle( defaultSavedFlag );
if ( !defaultSavedFlag )
{
QMessageBox::warning( this, tr( "Default Style" ), errorMsg );
}
}
Luigi Pirelli
**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
* https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
**************************************************************************************************
On 25 September 2017 at 13:44, Tom Chadwin <tom.chadwin at nnpa.org.uk> wrote:
> Perhaps you have to do it manually via a PostGIS query matching
> f_table_catalog, f_table_schema, and f_table_name, and updating styleqml and
> stylesld?
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the QGIS-Developer
mailing list