Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 150295
6 votes

How to change a project variable using Python?

In QGIS3, the API needs to pass QgsProject as the first argument. It is: setProjectVariable(project: QgsProject, name: str, value: Any) QgsExpressionContextUtils.setProjectVariable(QgsProject.instance …
Zac's user avatar
  • 527
3 votes

Set layer visibility using QgsMapCanvasLayer in QGIS 3?

The accepted answer is right and I simply want to mention that we can toggle on and off all the layers by: bool = True # or False root = QgsProject.instance().layerTreeRoot() allLayers = root.layerOr …
Zac's user avatar
  • 527
2 votes
1 answer
246 views

QgsExpression cannot get expected result when there is "\" in the string

I hope to use QgsFeatureRequest(QgsExpression) to get desired features. The statement in QgsExpression is: expr = QgsFeatureRequest(QgsExpression("\"planid\" in (48757) AND spi like '0\\%'") The feat …
Zac's user avatar
  • 527
3 votes

QGIS3 Python Plugin External Module

I use Mac and QGIS 3.4 and got the same error. After checking the PyQt5 folder in QGIS, I found there is no QtChart file in the folder, which is the reason why we cannot import it. And the version of …
Zac's user avatar
  • 527
5 votes
1 answer
304 views

Emitting signal when project property is changed using PyQGIS

QGIS API provides QgsExpressionContextUtils to set project properties. But in the class, there isn't any signal. I hope to connect to a signal whenever some of the properties were changed. So is there …
Zac's user avatar
  • 527
1 vote

How to enable a keyboard shortcut for a plugin

Having a look at the pyqgis cookbook , it said to add a shortcut in the initGui() method. self.key_action = QAction("Test Plugin", self.iface.mainWindow()) self.iface.registerMainWindowAction(self.key_action …
Zac's user avatar
  • 527
6 votes
0 answers
151 views

Is it safe to access layer object(e.g. QgsVectorLayer) in background task(QgsTask) in QGIS3

Because descriptions in PyQGIS cookbook are different with different versions. …
Zac's user avatar
  • 527
4 votes
Accepted

Hiding a layer in Layers panel, but showing in Map Canvas

I‘ve had the same question for a while and didn't find a proper solution. Thanks to @Germán Carrillo's post and plugin, I found a way. Thank you so much. Sorry I cannot install an extra plugin at work …
Zac's user avatar
  • 527
1 vote

Developing QGIS Python plugins using Jupyter?

There is an Ipython console(A kernel for Jupyter) for QGIS as a plugin, which you can add from QGIS official plugin repository or download from Github and copy to the plugin folder in QGIS. https: …
Zac's user avatar
  • 527
2 votes
Accepted

Using "Crtl + C" to copy an item from QTableWidget in QGIS, but get all attributes from a fe...

After looking into the issue for some time, I finally found out why this happend. Explain: The weird behaviour was caused by QGIS. Actually, there is a global shortcut for "Control+C" to copy the sele …
Zac's user avatar
  • 527
1 vote
1 answer
358 views

Using "Crtl + C" to copy an item from QTableWidget in QGIS, but get all attributes from a fe...

I am using PyQGIS to develop a table as a QGIS 3.4 plugin. The table is created by QTableWidget and looks good. …
Zac's user avatar
  • 527