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

Method theme() of QgsMapCanvas not in sync? #27499

Closed
qgib opened this issue Aug 23, 2018 · 13 comments
Closed

Method theme() of QgsMapCanvas not in sync? #27499

qgib opened this issue Aug 23, 2018 · 13 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Aug 23, 2018

Author Name: Darius G. (Darius G.)
Original Redmine Issue: 19674
Affected QGIS version: 3.4.3
Redmine category:python_bindings_/_sipify


iface.mapCanvas().theme() refers always to an empty string while user set map themes in the QGIS GUI interactively.

In addition you can also check this:

https://gis.stackexchange.com/questions/293507/how-to-read-out-which-map-theme-is-used-in-qgis-3


Related issue(s): #27594 (relates)
Redmine related issue(s): 19769


@qgib
Copy link
Contributor Author

qgib commented Sep 11, 2018

Author Name: Adam Szieberth (@SzieberthAdam)


Connects to #27594

It is weird that @qgc.QgsProject.instance().mapThemeCollection()@ can provide the list of map themes and can emit a signal when map theme changed but can not give the current/active/actual map theme. Also I found @applyTheme()@ overcomplicated as I would expect to give the name as a single argument and see the theme changed.

@qgib
Copy link
Contributor Author

qgib commented Sep 11, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2018

Author Name: Darius G. (Darius G.)


I have installed latest QGIS 3.4 and I have noticed that the bug is still not solved in this version?

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2018

Author Name: Giovanni Manghi (@gioman)


  • version was changed from 3.2.2 to 3.4.0

@qgib
Copy link
Contributor Author

qgib commented Dec 5, 2018

Author Name: Darius G. (Darius G.)


Bug still in QGIS 3.4.2 not solved.

@qgib
Copy link
Contributor Author

qgib commented Dec 5, 2018

Author Name: Giovanni Manghi (@gioman)


  • version was changed from 3.4.0 to 3.4.2
  • category_id was changed from Python plugins to Python bindings / sipify

@qgib
Copy link
Contributor Author

qgib commented Jan 9, 2019

Author Name: Darius G. (Darius G.)


Bug still in QGIS 3.4.3 not solved.

@qgib
Copy link
Contributor Author

qgib commented Jan 9, 2019

Author Name: Giovanni Manghi (@gioman)


  • version was changed from 3.4.2 to 3.4.3

@qgib
Copy link
Contributor Author

qgib commented Feb 5, 2019

Author Name: Darius G. (Darius G.)


Bug still in QGIS 3.4.4 not solved...

@qgib
Copy link
Contributor Author

qgib commented Feb 26, 2019

Author Name: Martin Dobias (@wonder-sk)


The main map canvas is "special" - it does not have map theme assigned. Instead when you pick a map theme, styles of map layers are modified according to the theme's settings. The theme attribute in QgsMapCanvas is used for other map canvases where user want to follow a specific map theme which is different from the current one.

So in fact this is not a bug, but I understand there's some confusion due to the way how the implementation works.

To figure out the current map theme (and that's how the map themes menu in qgis does it) is like this:

  1. get the current state using QgsMapThemeCollection::createThemeFromCurrentState( root, model ) (root and model come from QgsProject::instance())
  2. go through the map themes QgsProject::instance()->mapThemeCollection()->mapThemes() and for each have a look at their content QgsProject::instance()->mapThemeCollection()->mapThemeState( name ) and compare it to the current theme's content

@qgib
Copy link
Contributor Author

qgib commented Feb 26, 2019

Author Name: Darius G. (Darius G.)


Thank you very much for the feedback. I have implemented your procedure and it works.


  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Feb 26, 2019
@qgib
Copy link
Contributor Author

qgib commented Mar 1, 2019

Author Name: Giovanni Manghi (@gioman)


  • resolution was changed from to invalid

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API labels May 25, 2019
@alexMuellerKela
Copy link

Hi all, thanks for the described solution on Feb 26, 2019 - only this appears to be a riddle to me. I just do not understand where to go and what to do. I would be thankful if there would be some explanations, best based on the QGIS UI.
thanks so far

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! PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

2 participants