Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label not updated if triggered from user interaction with another layer #60016

Closed
1 of 2 tasks
DelazJ opened this issue Dec 26, 2024 · 2 comments
Closed
1 of 2 tasks

Label not updated if triggered from user interaction with another layer #60016

DelazJ opened this issue Dec 26, 2024 · 2 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Labeling Related to QGIS map labeling

Comments

@DelazJ
Copy link
Contributor

DelazJ commented Dec 26, 2024

What is the bug or the crash?

I'm trying to update the label of a layer depending on selected features on another layer, based on their spatial relationship. The map canvas refreshes automatically only if both layers are labeled.

Steps to reproduce the issue

Let's take two layers, "commune" and "region", that have features overlapping. And I want to label "region" depending on whether an overlapped "commune" is selected. I'm using:

with_variable(
  'containedcommunes'
  overlay_contains('commune', @feature)
  case
    when array_contains(array_foreach(@containedcommunes, is_selected('commune', @element)), 'true')
    then "nom_officiel"
    else "code_siren"
  end
)

When I select a feature in "commune":

  • if the commune layer has labeling enabled, the region's label changes as soon as I do the selection. The expression used for commune doesn't matter.
  • If commune layer is not labeled, the region's label doesn't change unless I pan/zoom/refresh somehow the canvas.
  • If another layer in the project is labeled, the region's label doesn't change either unless I pan/zoom/refresh somehow the canvas

Versions

Tested on Windows 10 with QGIS 3.41 98c5bf8

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@DelazJ DelazJ added Labeling Related to QGIS map labeling Bug Either a bug report, or a bug fix. Let's hope for the latter! labels Dec 26, 2024
@nyalldawson
Copy link
Collaborator

You need to setup the layer dependencies for things like this to work -- implicit dependencies from expressions are not automatically considered.

@DelazJ
Copy link
Contributor Author

DelazJ commented Dec 27, 2024

Oh, YESSSS! I forgot that tab. Thanks a lot, Nyall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Labeling Related to QGIS map labeling
Projects
None yet
Development

No branches or pull requests

2 participants