QgsScaleBarSettings class

The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with QgsScaleBarRenderer.

Public types

enum Alignment { AlignLeft = 0, AlignMiddle, AlignRight }
Scalebar alignment.
enum SegmentSizeMode { SegmentSizeFixed = 0, SegmentSizeFitWidth = 1 }
Modes for setting size for scale bar segments.

Constructors, destructors, conversion operators

QgsScaleBarSettings()
Constructor for QgsScaleBarSettings.

Public functions

auto alignment() const -> Alignment
Returns the scalebar alignment.
auto boxContentSpace() const -> double
Returns the spacing (margin) between the scalebar box and content in millimeters.
auto brush() const -> QBrush
Returns the primary brush used for filling the scalebar.
auto brush2() const -> QBrush
Returns the secondary brush for the scalebar.
auto fillColor() const -> QColor
Returns the color used for fills in the scalebar.
auto fillColor2() const -> QColor
Returns the secondary color used for fills in the scalebar.
auto font() const -> Q_DECL_DEPRECATED QFont deprecated
Returns the font used for drawing text in the scalebar.
auto fontColor() const -> Q_DECL_DEPRECATED QColor deprecated
Returns the color used for drawing text in the scalebar.
auto height() const -> double
Returns the scalebar height (in millimeters).
auto labelBarSpace() const -> double
Returns the spacing (in millimeters) between labels and the scalebar.
auto lineCapStyle() const -> Qt::PenCapStyle
Returns the cap style used for drawing lines in the scalebar.
auto lineColor() const -> QColor
Returns the color used for lines in the scalebar.
auto lineJoinStyle() const -> Qt::PenJoinStyle
Returns the join style used for drawing lines in the scalebar.
auto lineWidth() const -> double
Returns the line width in millimeters for lines in the scalebar.
auto mapUnitsPerScaleBarUnit() const -> double
Returns the number of map units per scale bar unit used by the scalebar.
auto maximumBarWidth() const -> double
Returns the maximum width (in millimeters) for scale bar segments.
auto minimumBarWidth() const -> double
Returns the minimum width (in millimeters) for scale bar segments.
auto numberOfSegments() const -> int
Returns the number of segments included in the scalebar.
auto numberOfSegmentsLeft() const -> int
Returns the number of segments included in the left part of the scalebar.
auto pen() const -> QPen
Returns the pen used for drawing outlines in the scalebar.
auto segmentSizeMode() const -> SegmentSizeMode
Returns the size mode for the scale bar segments.
void setAlignment(Alignment alignment)
Sets the scalebar alignment.
void setBoxContentSpace(double space)
Sets the space (margin) between the scalebar box and content in millimeters.
void setBrush(const QBrush& brush)
Sets the primary brush used for filling the scalebar.
void setBrush2(const QBrush& brush)
Sets the secondary brush used for filling the scalebar.
void setFillColor(const QColor& color)
Sets the color used for fills in the scalebar.
void setFillColor2(const QColor& color)
Sets the secondary color used for fills in the scalebar.
auto setFont(const QFont& font) -> Q_DECL_DEPRECATED void deprecated
Sets the font used for drawing text in the scalebar.
auto setFontColor(const QColor& color) -> Q_DECL_DEPRECATED void deprecated
Sets the color used for drawing text in the scalebar.
void setHeight(double height)
Sets the scalebar height (in millimeters).
void setLabelBarSpace(double space)
Sets the spacing (in millimeters) between labels and the scalebar.
void setLineCapStyle(Qt::PenCapStyle style)
Sets the cap style used when drawing the lines in the scalebar.
void setLineColor(const QColor& color)
Sets the color used for lines in the scalebar.
void setLineJoinStyle(Qt::PenJoinStyle style)
Sets the join style used when drawing the lines in the scalebar.
void setLineWidth(double width)
Sets the line width in millimeters for lines in the scalebar.
void setMapUnitsPerScaleBarUnit(double units)
Sets the number of map units per scale bar unit used by the scalebar.
void setMaximumBarWidth(double width)
Sets the maximum width (in millimeters) for scale bar segments.
void setMinimumBarWidth(double width)
Sets the minimum width (in millimeters) for scale bar segments.
void setNumberOfSegments(int segments)
Sets the number of segments included in the scalebar.
void setNumberOfSegmentsLeft(int segments)
Sets the number of segments included in the left part of the scalebar.
void setPen(const QPen& pen)
Sets the pen used for drawing outlines in the scalebar.
void setSegmentSizeMode(SegmentSizeMode mode)
Sets the size mode for scale bar segments.
void setTextFormat(const QgsTextFormat& format)
Sets the text format used for drawing text in the scalebar.
void setUnitLabel(const QString& label)
Sets the label for units.
void setUnits(QgsUnitTypes::DistanceUnit units)
Sets the distance units used by the scalebar.
void setUnitsPerSegment(double units)
Sets the number of scalebar units per segment.
auto textFormat() -> QgsTextFormat&
Returns the text format used for drawing text in the scalebar.
auto textFormat() const -> QgsTextFormat
Returns the text format used for drawing text in the scalebar.
auto unitLabel() const -> QString
Returns the label for units.
auto units() const -> QgsUnitTypes::DistanceUnit
Returns the distance units used by the scalebar.
auto unitsPerSegment() const -> double
Returns the number of scalebar units per segment.

Enum documentation

enum QgsScaleBarSettings::Alignment

Scalebar alignment.

Enumerators
AlignLeft

Left aligned.

AlignMiddle

Center aligned.

AlignRight

Right aligned.

enum QgsScaleBarSettings::SegmentSizeMode

Modes for setting size for scale bar segments.

Enumerators
SegmentSizeFixed

Scale bar segment size is fixed to a map unit.

SegmentSizeFitWidth

Scale bar segment size is calculated to fit a size range.

Function documentation

Alignment QgsScaleBarSettings::alignment() const

Returns the scalebar alignment.

double QgsScaleBarSettings::boxContentSpace() const

Returns the spacing (margin) between the scalebar box and content in millimeters.

QBrush QgsScaleBarSettings::brush() const

Returns the primary brush used for filling the scalebar.

QBrush QgsScaleBarSettings::brush2() const

Returns the secondary brush for the scalebar.

This is used for alternating color style scalebars, such as single and double box styles.

QColor QgsScaleBarSettings::fillColor() const

Returns the color used for fills in the scalebar.

QColor QgsScaleBarSettings::fillColor2() const

Returns the secondary color used for fills in the scalebar.

Q_DECL_DEPRECATED QFont QgsScaleBarSettings::font() const

Returns the font used for drawing text in the scalebar.

Q_DECL_DEPRECATED QColor QgsScaleBarSettings::fontColor() const

Returns the color used for drawing text in the scalebar.

double QgsScaleBarSettings::height() const

Returns the scalebar height (in millimeters).

double QgsScaleBarSettings::labelBarSpace() const

Returns the spacing (in millimeters) between labels and the scalebar.

Qt::PenCapStyle QgsScaleBarSettings::lineCapStyle() const

Returns the cap style used for drawing lines in the scalebar.

QColor QgsScaleBarSettings::lineColor() const

Returns the color used for lines in the scalebar.

Qt::PenJoinStyle QgsScaleBarSettings::lineJoinStyle() const

Returns the join style used for drawing lines in the scalebar.

double QgsScaleBarSettings::lineWidth() const

Returns the line width in millimeters for lines in the scalebar.

double QgsScaleBarSettings::mapUnitsPerScaleBarUnit() const

Returns the number of map units per scale bar unit used by the scalebar.

double QgsScaleBarSettings::maximumBarWidth() const

Returns the maximum width (in millimeters) for scale bar segments.

This property is only effective if the segmentSizeMode() is set to SegmentSizeFitWidth.

double QgsScaleBarSettings::minimumBarWidth() const

Returns the minimum width (in millimeters) for scale bar segments.

This property is only effective if the segmentSizeMode() is set to SegmentSizeFitWidth.

int QgsScaleBarSettings::numberOfSegments() const

Returns the number of segments included in the scalebar.

int QgsScaleBarSettings::numberOfSegmentsLeft() const

Returns the number of segments included in the left part of the scalebar.

QPen QgsScaleBarSettings::pen() const

Returns the pen used for drawing outlines in the scalebar.

SegmentSizeMode QgsScaleBarSettings::segmentSizeMode() const

Returns the size mode for the scale bar segments.

void QgsScaleBarSettings::setAlignment(Alignment alignment)

Sets the scalebar alignment.

void QgsScaleBarSettings::setBoxContentSpace(double space)

Sets the space (margin) between the scalebar box and content in millimeters.

void QgsScaleBarSettings::setBrush(const QBrush& brush)

Sets the primary brush used for filling the scalebar.

void QgsScaleBarSettings::setBrush2(const QBrush& brush)

Sets the secondary brush used for filling the scalebar.

void QgsScaleBarSettings::setFillColor(const QColor& color)

Sets the color used for fills in the scalebar.

void QgsScaleBarSettings::setFillColor2(const QColor& color)

Sets the secondary color used for fills in the scalebar.

Q_DECL_DEPRECATED void QgsScaleBarSettings::setFont(const QFont& font)

Sets the font used for drawing text in the scalebar.

Q_DECL_DEPRECATED void QgsScaleBarSettings::setFontColor(const QColor& color)

Sets the color used for drawing text in the scalebar.

void QgsScaleBarSettings::setHeight(double height)

Sets the scalebar height (in millimeters).

void QgsScaleBarSettings::setLabelBarSpace(double space)

Sets the spacing (in millimeters) between labels and the scalebar.

void QgsScaleBarSettings::setLineCapStyle(Qt::PenCapStyle style)

Sets the cap style used when drawing the lines in the scalebar.

void QgsScaleBarSettings::setLineColor(const QColor& color)

Sets the color used for lines in the scalebar.

void QgsScaleBarSettings::setLineJoinStyle(Qt::PenJoinStyle style)

Sets the join style used when drawing the lines in the scalebar.

void QgsScaleBarSettings::setLineWidth(double width)

Sets the line width in millimeters for lines in the scalebar.

void QgsScaleBarSettings::setMapUnitsPerScaleBarUnit(double units)

Sets the number of map units per scale bar unit used by the scalebar.

void QgsScaleBarSettings::setMaximumBarWidth(double width)

Sets the maximum width (in millimeters) for scale bar segments.

This property is only effective if the segmentSizeMode() is set to SegmentSizeFitWidth.

void QgsScaleBarSettings::setMinimumBarWidth(double width)

Sets the minimum width (in millimeters) for scale bar segments.

This property is only effective if the segmentSizeMode() is set to SegmentSizeFitWidth.

void QgsScaleBarSettings::setNumberOfSegments(int segments)

Sets the number of segments included in the scalebar.

void QgsScaleBarSettings::setNumberOfSegmentsLeft(int segments)

Sets the number of segments included in the left part of the scalebar.

void QgsScaleBarSettings::setPen(const QPen& pen)

Sets the pen used for drawing outlines in the scalebar.

void QgsScaleBarSettings::setSegmentSizeMode(SegmentSizeMode mode)

Sets the size mode for scale bar segments.

void QgsScaleBarSettings::setTextFormat(const QgsTextFormat& format)

Sets the text format used for drawing text in the scalebar.

void QgsScaleBarSettings::setUnitLabel(const QString& label)

Sets the label for units.

void QgsScaleBarSettings::setUnits(QgsUnitTypes::DistanceUnit units)

Sets the distance units used by the scalebar.

void QgsScaleBarSettings::setUnitsPerSegment(double units)

Sets the number of scalebar units per segment.

QgsTextFormat& QgsScaleBarSettings::textFormat()

Returns the text format used for drawing text in the scalebar.

QgsTextFormat QgsScaleBarSettings::textFormat() const

Returns the text format used for drawing text in the scalebar.

QString QgsScaleBarSettings::unitLabel() const

Returns the label for units.

QgsUnitTypes::DistanceUnit QgsScaleBarSettings::units() const

Returns the distance units used by the scalebar.

double QgsScaleBarSettings::unitsPerSegment() const

Returns the number of scalebar units per segment.