Hot answers tagged

9 votes

PyQt signal when layer name is changed in PyQGIS

Use the nameChanged signal of QgsLayerTreeNode class. from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot()...
Kadir Şahbaz's user avatar
7 votes
Accepted

Counting seconds using QTimer in PyQGIS

For what you are trying to do, QTimer.singleShot() is not really what you want. I would suggest setting an interval, then connecting your slot function to the timeout signal of QTimer and calling ...
Ben W's user avatar
  • 20.6k
3 votes

AttributeError when creating list field with QVariant in QgsVectorLayer using PyQGIS

I could get the same error as you: Traceback (most recent call last): File "C:\PROGRA~1\QGIS32~1.0\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "&...
Taras's user avatar
  • 31.4k
2 votes

Counting seconds using QTimer in PyQGIS

Without classes or global variables: from itertools import count timer_printer = lambda t: print(t) counter = count(1) # start at 1 timer = QTimer() timer.setInterval(1000) # 1000 milliseconds = 1 ...
J. Monticolo's user avatar
  • 15.7k
2 votes

QGIS3 quits after PyQt Script 2 run

If you want to run your code inside QGIS, you don't need the QApplication() call import sys from PyQt5.QtCore import (QSize, Qt) from PyQt5.QtWidgets import (QApplication, ...
Louis Cottereau's user avatar
2 votes
Accepted

Error with PyScripter and QGIS 3.22, can't find DLL

I found another workaround: because setting the DLL search path automatically changed in Python 3.8, you have to do this explicitly in your script. I use a start-script for the Python-Interpreter ...
Andreas Müller's user avatar
1 vote

Pyqt5 : dynamically change label value, with no clicking signal

In the end I used the showEvent method : it is called right away, without waiting for a user action. def showEvent(self,showEvent): self.fillComboBox() It is very useful !
theonewhodidnotknow's user avatar
1 vote
Accepted

Error when importing another py and ui files in my QGIS plugin

It was in fact a basic error, I forgot the breaks after the 'show' function... Just in case it would help, when using show() I can still interact with the main window. However, if I use exec_(), the ...
theonewhodidnotknow's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible