Skip to content

Add control over layout scale bar unit position - #67392

Open
nyalldawson wants to merge 4 commits into
qgis:masterfrom
nyalldawson:legend_text_pos
Open

nyalldawson wants to merge 4 commits into
qgis:masterfrom
nyalldawson:legend_text_pos

Conversation

@nyalldawson

Copy link
Copy Markdown
Collaborator

Description

Instead of forcing the units to always be placed after the last distance label, users now have a choice of exactly where they want them placed.

Options are:

  • Vertically centered on the bar, before the bar begins
  • Vertically centered on the bar, after the bar ends
  • Text centered over the left edge of the bar, above the bar
  • Horizontally centered on the bar, above the bar
  • Text centered over the right edge of the bar, above the bar
  • Text centered over the left edge of the bar, below the bar
  • Horizontally centered on the bar, below the bar
  • Text centered over the right edge of the bar, below the bar
  • Placed before the first distance label
  • Placed after the last distance label
  • Placed on top of the bar, after the first bar division
  • Placed before every distance label (as part of the distance label text)
  • Placed after every distance label (as part of the distance label text)

Multiple options may be selected, allowing for fully flexible unit label positioning.

Sponsored by the QGIS Swiss User Group

AI tool usage

  • Gemini was used to assist with text placement metrics

@nyalldawson nyalldawson added Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 11, 2026
@qgis-bot

Copy link
Copy Markdown
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions Bot added this to the 4.4.0 milestone Sep 11, 2026
@qgis-bot

Copy link
Copy Markdown
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@github-actions github-actions Bot added GUI/UX Related to QGIS application GUI or User Experience Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks labels Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
To execute locally, unzip the downloaded zip file and run bin\qgis-bin.exe in the extracted directory.
You might be prompted by Windows Defender click "Run anyway"
(Built from commit 17d8809)

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This app is not notarized, run sudo xattr -d com.apple.quarantine /Applications/QGIS*.app to avoid the warning
(Built from commit 17d8809)

@qgis qgis deleted a comment from github-actions Bot Sep 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tests failed for Qt 6 (ALL_BUT_PROVIDERS - ubuntu)

One or more tests failed using the build from commit 04d5fac

importComposerTemplateScaleBar_0 (importComposerTemplateScaleBar)

importComposerTemplateScaleBar_0

Test failed at importComposerTemplateScaleBar at tests/src/core/testqgscompositionconverter.cpp:487

Rendered image did not match tests/testdata/control_images/compositionconverter/expected_importComposerTemplateScaleBar_0/expected_importComposerTemplateScaleBar_0.png (found 215 pixels different)

importComposerTemplate_0 (importComposerTemplate)

importComposerTemplate_0

Test failed at importComposerTemplate at tests/src/core/testqgscompositionconverter.cpp:643

Rendered image did not match tests/testdata/control_images/compositionconverter/expected_importComposerTemplate_0/expected_importComposerTemplate_0.png (found 215 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

@github-actions

Copy link
Copy Markdown
Contributor

Tests failed for Qt 6 (ALL_BUT_PROVIDERS - fedora)

One or more tests failed using the build from commit 04d5fac

importComposerTemplateScaleBar_0 (importComposerTemplateScaleBar)

importComposerTemplateScaleBar_0

Test failed at importComposerTemplateScaleBar at tests/src/core/testqgscompositionconverter.cpp:487

Rendered image did not match tests/testdata/control_images/compositionconverter/expected_importComposerTemplateScaleBar_0/expected_importComposerTemplateScaleBar_0.png (found 215 pixels different)

importComposerTemplate_0 (importComposerTemplate)

importComposerTemplate_0

Test failed at importComposerTemplate at tests/src/core/testqgscompositionconverter.cpp:643

Rendered image did not match tests/testdata/control_images/compositionconverter/expected_importComposerTemplate_0/expected_importComposerTemplate_0.png (found 215 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

Instead of forcing the units to always be placed after the last
distance label, users now have a choice of exactly where they want
them placed.

Options are:

Vertically centered on the bar, before the bar begins
Vertically centered on the bar, after the bar ends
Text centered over the left edge of the bar, above the bar
Horizontally centered on the bar, above the bar
Text centered over the right edge of the bar, above the bar
Text centered over the left edge of the bar, below the bar
Horizontally centered on the bar, below the bar
Text centered over the right edge of the bar, below the bar
Placed before the first distance label
Placed after the last distance label
Placed on top of the bar, after the first bar division
Placed before every distance label (as part of the distance label text)
Placed after every distance label (as part of the distance label text)

Multiple options may be selected, allowing for fully flexible
unit label positioning.

Sponsored by the QGIS Swiss User Group
{
// fallback to older attribute, appending the space which was previously always
// added by the scalebar renderer
mSettings.setUnitLabel( itemElem.attribute( u"unitLabel"_s ) + ' ' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the space be preprended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature GUI/UX Related to QGIS application GUI or User Experience Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants