from qgis.core import QgsSettings settings = QgsSettings() shape_tolerance = settings.value("AdvancedDigitizing/ShapeDigitizeTolerance", defaultValue=0.0001, type=float) print("Shape digitizing tolerance:", shape_tolerance)
from qgis.core import QgsSettings, QgsColorSchemeRegistry, QgsColorRampShader settings = QgsSettings() custom_colors = ["#FF0000", "#00FF00", "#0000FF"] ramp = QgsColorRampShader() ramp.setColor1(QgsColorSchemeRegistry.instance().scheme("Red").color(QgsColorSchemeRegistry.BackgroundColor)) ramp.setColor2(QgsColorSchemeRegistry.instance().scheme("Blue").color(QgsColorSchemeRegistry.BackgroundColor)) ramp.setColor3(QgsColorSchemeRegistry.instance().scheme("Green").color(QgsColorSchemeRegistry.BackgroundColor)) ramp.setColor4(QgsColorSchemeRegistry.instance().scheme("Yellow").color(QgsColorSchemeRegistry.BackgroundColor)) settings.setValue("ColorRamp/Spectral", ramp.exportXml())This code sets a custom color ramp for QGIS, using the "ColorRamp/Spectral" setting. It defines four colors to be used in the ramp, and sets them as the colors of the new custom color ramp. In conclusion, QgsSettings is a useful class in the QGIS library for accessing and setting QGIS settings, and can be used in a range of applications such as plugin development and interface customization.