23
votes
QGIS plugin: Problems importing resources (resources_rc) file - plugin doesn't load - PATH problems?
This problem is caused by uic not working properly. I am not sure exactly why but I can show the symptoms and a workaround.
The initial plugin .ui file has an empty resources element:
<resources/...
14
votes
QGIS plugin: Problems importing resources (resources_rc) file - plugin doesn't load - PATH problems?
You can avoid having to edit the .ui file or compiling, etc by doing the following:
import sys
sys.path.append(os.path.dirname(__file__))
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path....
11
votes
Should you switch from ArcMap to QGIS?
It's not easy just to switch to QGIS if you've decided to stay invested in the Arc-Geodatabase. I would say don't switch. You'll have more trouble mixing the technologies than it would be worth.
The ...
11
votes
Accepted
how do I create simple yes/no dialog in qgis python plugin?
Use QMessageBox.question:
from PyQt4 import QtGui
reply = QMessageBox.question(self.iface.mainWindow(), 'Continue?',
'Your message here', QMessageBox.Yes, QMessageBox.No)
if reply ==...
10
votes
Accepted
QGIS relations widget in custom form
In Qt Designer:
Create a new QWidget
Add a custom property and name it qgisRelation
Set the value of the new qgisRelation-property to the id of the relation.
10
votes
Accepted
Adding a Tiles/wms? (openStreetMap) layer with python in QGIS
Tiles/WMS sources give you raster data. So, you have to use QgsRasterLayer() instead of QgsVectorLayer().
Try in this way:
...
rlayer = QgsRasterLayer(urlWithParams, 'OpenStreetMap', 'wms') # ...
9
votes
Accepted
Populating combobox with layers in TOC using PyQGIS?
layers = QgsMapLayerRegistry.instance().mapLayers().values()
for layer in layers:
if layer.type() == QgsMapLayer.VectorLayer and layer.geometryType() == QGis.Line:
self.dlg.ui.layerCombo....
9
votes
QGIS plugin: Problems importing resources (resources_rc) file - plugin doesn't load - PATH problems?
I finally fixed it after 3 hours of trying.
As someone said QT Designer adds
<resources>
<include location="resources.qrc"/>
</resources>
to your UI file. I simply deleted those ...
9
votes
Accepted
Work around for “Couldn’t load PyQt” error with QGIS 3.0.3 on Ubuntu 18.04?
I was able to reproduce this error by installing PyQt5 using the Python package manager. If you remove the Python-managed PyQt5 and instead install the OS version, QGIS should launch. I have confirmed ...
9
votes
Accepted
How to fix 'Could not find the Qt platform plugin “Windows” in “”' when implementing qgis in custom Python3 application?
Add the following environment variables at the beginning of your python script before loading qgis.core:
#modify environment variables to find qgis and qt plugins during qgis.core import
os.environ['...
8
votes
Accepted
Do I have to publish own QGIS plugins?
Do you have to publish it?
Legally, The GPL License of PyQGIS forces you to share the code only with your "client", therefore your company.
So No, you don't have to publish it. You can keep them ...
7
votes
QGIS relations widget in custom form
Use a custom form designed using Qt designer.
(I've been successful doing this on QGIS 2.6 on Windows, but my Linux QGIS version crashes. I'm writing this having worked things out for the first time ...
7
votes
Accepted
Opening Plugin with another Plugin
For my example, I took the QGIS plugin Plugin Builder 3 (link).
After install of this plugin, a new repository is made in :
\QGIS\QGIS3\profiles\default\python\plugins\pluginbuilder3
(here is the ...
6
votes
Should you switch from ArcMap to QGIS?
Benefits for switching:
No license cost per user!
May integrate with other open source apps. (e.g. GeoServer, MapServer, PostGIS..etc)
Plug-in language built on C++/python (pyQGIS)
Not as buggy
...
6
votes
Accepted
How to add loading bar in QGIS Plugin development?
A good and user friendly way to do it is using the QgsMessageBar class.
A first look here by the author of this class:
http://nathanw.net/2013/08/02/death-to-the-message-box-use-the-qgis-messagebar/
...
6
votes
Accepted
How to sort layers within groups with Python?
Sorting layers is a particularly painful task in PyQGIS, because of the lack of suitable methods in the QgsLayerTreeNode class. Based on your code, I managed to write a console script that seems to ...
6
votes
Accepted
Keep UI Settings for a QGIS plugin
Right, you need to use QSettings to store values across QGIS sessions. QSettings is multi-platform, so you don't need to worry about where it stores the data on Linux, on Windows, or on Mac, it ...
6
votes
Accepted
How to show only postgres vector layers in a QgsMapLayerComboBox?
In QGIS 2.x you'd need to pass a list of layers not coming from PostgreSQL:
excepted = []
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
if hasattr(layer, 'providerType') and ...
6
votes
How to use QT QGis custom widget in a plugin?
To properly use QT QGis custom widgets:
Use imports such as:
from PyQt4.QtGui import QDialog
from qgis.gui import QgsFileWidget
You must also edit the xx_dialog_base.ui file, to ensure that the ...
6
votes
Accepted
QComboBox multiple selection - PyQT5
For anyone interested, here is an implementation of a CheckableComboBox.
class CheckableComboBox(QComboBox):
# Subclass Delegate to increase item height
class Delegate(QStyledItemDelegate):
...
6
votes
Accepted
Connecting Qt GUI to python code in QGIS Plugin
Your "check boxes" don't work because you're putting your lines in the wrong place (run method). However, you need first to declare objects in __init__ method for connecting them to a 'change_status' ...
6
votes
Accepted
Making a Feature Form for a standalone PyQGIS application as in QGIS
The following script generates a simple form. You can use it in your standalone PyQGIS application to display attributes for a given feature. You can also specify fields to be displayed (or not to be ...
6
votes
Accepted
Capturing CTRL+Key In KeyPressEvent in PyQGIS QgsMaptool
QKeyEvent has a method modifiers(). You should use it.
def keyPressEvent(self, event):
if event.modifiers() & Qt.ControlModifier:
if event.key() == Qt.Key_R:
print("...
6
votes
Accepted
Display a progressBar and use the execution time of several functions in QGIS plugin
Add a variable to the first function to store starting time. For example (self.start). Define a new function to set progress. Then use that function instead of setValue in other functions called by ...
5
votes
QGIS Plugin with save settings dialog
You can use QSettings to read and write settings. It takes care of storing the settings on all platforms without you having to find a place to write a file.
I used this functionality in the Google ...
5
votes
QGIS Plugin with save settings dialog
Yes, you can store settings in separate files/ways with QSettings, and within the same Q(Core)Application. This makes it ideal for what you are looking to do.
When initializing your PyQGIS plugin's ...
5
votes
Accepted
Purpose of "myPlugin_dialog.py" file created by QGIS Plugin Builder
Technically the only files you need for a plugin are:
__init__.py
metadata.txt
plugin.py
All the other files are just extra stuff depending on what you plugin does. If you don't need any resources (...
5
votes
Accepted
Programmatically change layer position in the table of contents (QGIS)
By using the new Layer tree (aka legend or Toc) added by Martin Dobias since QGIS v.2.4, you can load a layer to the bottom of the ToC following these steps:
Get a reference of the layer tree
root = ...
5
votes
How to use Threads in PyQgis, mainly to keep UI active?
Use processing in QGIS 3.x
In QGIS 3.x there is an infrastructure in place to have things running in threads. Processing is a good candidate to be what you are looking for when doing "heavy ...
5
votes
Accepted
How to position the Qwidget form/QDialogBox in the left corner using python programming
I'll answer the question that is stated in the title.
You can use the following code to show your dialog in the bottom-left corner (do all this right before the call to self.dlg.show()):
ph = ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pyqt × 256pyqgis × 180
qgis × 122
qgis-plugins × 88
python × 64
qt-designer × 15
qt × 13
qgis-3 × 12
python-2.7 × 11
pyqt5 × 10
pyqgis-3 × 9
qgis-2 × 8
qgis-processing × 7
plugins × 7
python-3 × 6
standalone × 6
pyqt4 × 6
mac × 5
gui × 5
gdal × 4
attribute-table × 4
qt4 × 3
arcpy × 2
sql × 2
installation × 2