Questions tagged [pyqt]
PyQt provides bindings for Qt 2 and Qt 3.
276
questions
16
votes
10
answers
19k
views
QGIS plugin: Problems importing resources (resources_rc) file - plugin doesn't load - PATH problems?
I'm building qgis plugin and I can't find solution for this error.
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, ...
13
votes
4
answers
9k
views
Developing GUI in Python for ArcGIS geoprocessing using PyQT/Tkinter/wxPython?
I want to develop a GUI in Python for ArcGIS geoprocessing.
Can I use PyQT for GUI programming in ArcGIS?
I have also considered using Tkinter and wxPython.
8
votes
2
answers
6k
views
QGIS relations widget in custom form
I've just begun exploring QGIS relations option, now in version QGIS 2.2, details here: http://blog.vitu.ch/10112013-1201/qgis-relations
This is a great implementation of something I've been ...
8
votes
1
answer
21k
views
How to fix 'Could not find the Qt platform plugin “Windows” in “”' when implementing qgis in custom Python3 application?
I am implementing qgis 3.4.3 in a custom application, but when I instantiate the QgsApplication() class, I receive the error "Could not find the Qt platform plugin "Windows" in "".
I've attempted ...
8
votes
1
answer
658
views
Do I have to publish own QGIS plugins?
If I develop QGIS plugins for my company do I have to make them available to others? I use QT-Designer and think that it also depends on the question how you develop your plugins, right?
For example:
...
8
votes
1
answer
3k
views
Programmatically change layer position in the table of contents (QGIS)
I am trying move/position a layer to the bottom of the TOC by using addTopLevelItem on all other layers. I unsure how to reference the layers as QTreeWidgetItem's.
def bg_bottom_level_item(self):
...
8
votes
3
answers
4k
views
How to use Threads in PyQgis, mainly to keep UI active?
I'm trying to develop a plugin, which does heavy computations and as a result, user interface becomes inactive. I know that I should use threads to keep the UI alive (specifically, I have a progress ...
8
votes
2
answers
1k
views
Custom forms feature in QGIS: QMessageBox.warning closes QDialog as well
I am attempting to work with custom forms in QGIS. I have included a validate function in my code that will pop a QMessageBox() if the validation fails. My problem is that when I close the QMessageBox ...
8
votes
2
answers
1k
views
Remove "Save As" from QGIS Context Menu Using PyQGIS [closed]
I want to remove an existing option ("Save As") from context menu of QGIS layer, what I have found so far is, to add new action in the LegendItems, or overwrite completely with new options. But could ...
7
votes
4
answers
19k
views
QComboBox multiple selection - PyQT5
I'm making the gui for my QGIS3 plugin using PyQT5 and QT designer. I have a very long list of items in a QComboBox and I need the user to be able to select one or more items. I know that QComboBox ...
7
votes
1
answer
862
views
Moving cursor using PyQGIS?
I would like to move the cursor to a given x,y coordinates of the MapCanvas.
Is there an easy way to do this using PyQGIS?
7
votes
1
answer
516
views
Get xy coordinates of QgsMapCanvas in PyQGIS 3?
I am trying to get the QgsMapCanvas coordinates when they change using PyQt5 and PyQGIS 3. What I have used for that:
self.canvas.scaleChanged.connect(lambda: self.showScale(self.canvas.scale()))
...
6
votes
1
answer
3k
views
Adding a Tiles/wms? (openStreetMap) layer with python in QGIS
In my QGIS python plugin I want to add a background map (if the user haven't added one), hence I think I missing something in the url for the Tiles/wms service.. (the function returns invalid layer) ...
6
votes
2
answers
3k
views
Usage of QgsTask and QgsTaskManager
I'm trying to test the new QgsTask and QgsTaskManager, I found some examples in the PullRequest in github. I modified it slightly and added a print(i) in the code bellow:
from qgis.core import ...
6
votes
1
answer
8k
views
Making a Feature Form for a standalone PyQGIS application as in QGIS
In QGIS, there is a method named openFeatureForm defined in QgisInterface class. It opens a form that shows value of attributes for a given feature.
layer = iface.activeLayer()
feature = layer....
6
votes
1
answer
788
views
Keep UI Settings for a QGIS plugin
I'm writing a plugin that interacts with external software (hydrological models).
One of the dialogs has a lot of entries (parameters to pass to the hydrological software).
Once the user has set up ...
6
votes
1
answer
570
views
Running function from double click with PyQGIS
How can a double-click in the QGIS canvas be used to run a function in PyQGIS?
For example, I want to access the name of each feature I'm selecting with a double-click.
Code sample to access the ...
6
votes
1
answer
2k
views
Disabling automatic selection in QgsMapLayerComboBox
I build a plugin. It has a lot of comboboxes (QgsMapLayerComboBox). They are all empty when no project is loaded. When I open a project in QGIS, a layer is automatically shown in all comboboxes. All ...
6
votes
1
answer
2k
views
how to open second window in my plugin for QGIS?
I create a Mainwindow for my plugin, but if I want to open a second window from this Mainwindow, with click on push button. How can I do?
I tried the following function in my Main Class:
dialog = ...
6
votes
0
answers
2k
views
Connect to QGIS 2.6 Python Plugin function via button on custom feature form
I am trying to connect to a QGIS 2.6 Python plugin function via a custom feature form button.
On my feature form, I'm attempting to do a few things :
enable the updateButton only if the ...
5
votes
3
answers
4k
views
Should you switch from ArcMap to QGIS? [closed]
Background:
Our group has full ESRI licenses and applications built with ArcGIS Desktop.
We are invested in the arc geodatabase itself and will not change that tier.
There is a proposal to switch ...
5
votes
4
answers
1k
views
QGIS Plugin with save settings dialog
I am writing on an update of the qgis2leaf plugin.
It would be great to store the settings of the plugin UI (like which checkboxes are checked, which strings are used) in a separate file (like xml or ...
5
votes
2
answers
134
views
What is QDomNode and QDomDocument in terms of PyQGIS?
On a low level what is QDomNode and QDomDocument in the PyQGIS context?
I comprehend that both QDomNode and QDomDocument are derived from PyQt. Hence, with my limited knowledge of PyQt, I simply do ...
5
votes
1
answer
2k
views
Work around for “Couldn’t load PyQt” error with QGIS 3.0.3 on Ubuntu 18.04?
I am working with a fresh install of Ubuntu 18.04 and installed QGIS using https://qgis.org/debian. I get the following error when I launch QGIS:
Couldn't load PyQt.
Python support will be disabled.
...
5
votes
2
answers
795
views
Properter to get travel time as cost for network analysis
What I want to do is calculate travel times between points within a road network. I know there are options with GRASS (via v.net) and pgRouting (and possibly many more). I intent to stick to the ...
5
votes
1
answer
3k
views
Capturing CTRL+Key In KeyPressEvent in PyQGIS QgsMaptool
I created a Line with help of QgsMapTool and I'm able to capture the single key in keyPressEvent like this:
class buildingEditTool(QgsMapToolEdit):
def keyPressEvent(self, event):
...
5
votes
1
answer
1k
views
Download file from network using PyQGIS 2.x
I have a python plugin targeting QGIS 1.8 that uses QgsNetworkAccessManager and QNetworkRequest to issue a GetCapabilities request to WMS servers.
With 1.8 everything was working fine. Now we are ...
5
votes
1
answer
949
views
How to create sub-menus in QGIS 3 plugin
I'm trying to create a sub-menu in a QGIS plugin like in the image. I found this Add extra item to drop down menu plugin. "Layers menu from project" plugin but I'm using QGIS 3 and PyQT5 and ...
5
votes
1
answer
3k
views
Using PyQGIS in standalone scripts without crashing
I am new to the PyQGIS API.
For developing I use my Spyder IDE with QGIS and GRASS modules. In order to make my script executable I just run my code with the QGIS python.exe in my bat file. This all ...
5
votes
1
answer
340
views
Referencing Qt UIs external to plugin with python
I'm developing a plugin that sets up a working environment for a user: loading layers (from db), applying styles and several custom designed (Qt) UI files etc.
Primary user interaction is in the ...
5
votes
2
answers
1k
views
Drop down list QGIS Plugin based on keyword search
I am developing a QGIS plugin, using python and Plugin Builder plugin of QGIS. I have created a textEdit text box on the plugin. I want to show a list of matching words from the database as user will ...
5
votes
1
answer
1k
views
Add extra item to drop down menu plugin. "Layers menu from project" plugin
I have created a drop down menu in QGIS. The code is mainly from the "Layers menu from project" plugin. I have cleaned it so it only have the drop down.
My problem is that I will like to add an ...
5
votes
1
answer
657
views
QGIS Python Plugin - Prevent Dialog From Closing Immediately after OK Clicked
I've generated a QGIS plugin using the QGIS Plugin Builder v3.0.3. One issue I am encountering with it is - as soon as I click the "OK" button (that invokes the run method) - the dialog closes. Is ...
4
votes
2
answers
9k
views
how do I create simple yes/no dialog in qgis python plugin?
I'm making a QGIS plugin that processes a dataset. I started with pluginbuilder and have a GUI that allows me to set what to do.
As my plugin is making changes, when it detects a certain threshold of ...
4
votes
1
answer
120
views
PyQGIS Contour Labelling
I have generated contours using gdal:contour in a pyqgis plugin but am unable to add labels to them. This is the code that I have been trying to get working, but obviously doing something wrong.
...
4
votes
2
answers
575
views
How to show only postgres vector layers in a QgsMapLayerComboBox?
I started to develop a plugin for QGIS in python and I need to list postgres layers in a QgsMapLayerComboBox. I used a QgsMapLayerProxyModel to show only vector layers from canvas:
self.dlg.comboBox....
4
votes
1
answer
102
views
Connecting signals to different functions based on combobox selection
I'm working on a Qgis plugin (using QT Designer). The goal of the plugin is, depending on the combobox, clicking on a button will launch different functions.
For example, choosing "Images - WMS&...
4
votes
1
answer
2k
views
Connecting Qt GUI to python code in QGIS Plugin
I am completely new to PyQGIS/PyQt and am having lots of trouble getting started. I have managed to create my base dialog box like so:
The (automatically generated) code for the dialog is:
import os
...
4
votes
1
answer
1k
views
How to sort layers within groups with Python?
After running a longer script (Qgis Console), all I want to do is sort the layers within my groups;
since some of them are buffers and the 'biggest' buffer is now on top.
I've tried stuff based on: ...
4
votes
1
answer
1k
views
How to add loading bar in QGIS Plugin development?
Every time i use tool or plugin in QGIS, i saw a kind of bar like this for indicating loading progress :
The different between that bar and Progress Bar is that progress bar will increase until our ...
4
votes
1
answer
150
views
Change Qt dial size in .ui file, PyQGIS plugin
The main dialog in the plugin is entirely defined by an .ui file. No css stylesheet yet, nor processing (except for some values, not to define the controls).
I need a 2nd dial but its function is ...
4
votes
1
answer
4k
views
Error "No module named PyQt5.QtCore" in QGIS standalone application
import os, sys
sys.path.append(r'C:\Program Files\QGIS 3.6\apps\qgis\python')
sys.path.append(r'C:\Program Files\QGIS 3.6\apps\qgis\bin')
sys.path.append(r'C:\Program Files\QGIS 3.6\apps\Python37')
...
4
votes
1
answer
851
views
How to connect QgsMapLayerComboBox to QgsDataDefinedButton
in Qt Designer there is the possibility to use directly QGIS custom widgets.
In the UI I added a QgsMapLayerComboBox (to get the layers added in the legend) and a QgsDataDefinedButton.
What I would ...
4
votes
1
answer
262
views
Collapsing legend in ToC via PyQGIS
I am creating QGIS simple plugin which adds and set styles. It works like a charm, however i want to collapse all legends(categories) from styles in given layer i tried
layer....
4
votes
1
answer
963
views
Getting screen coordinates from canvas coordinate using PyQGIS
I'm trying to set the initial position of my QGIS plugin dialog. I'm using .setGeometry() but the problem is that I don't know how to get coordinates. I want to set the initial position in the top ...
4
votes
1
answer
864
views
Plugin builder - how to validate input values from a plugin dialog
I have a question regarding adding a warning popup when a user pressed OK while forgetting to fill in all the required fields in the plugin dialog.
I have the following definition which checks if all ...
4
votes
1
answer
271
views
Python QGIS plugin could not load on linux build in window
I have created a plugin in QGIS windows version using
"Plugin Builder". which on a button click opens another window, that is calling another class in the dialgoue python file, with another .ui file. ...
4
votes
1
answer
1k
views
Loading Shapefile in a standalone PyQGis App
I'd like to open a shapefile in a standalone PyQGis App. The App starts and runs without a problem but a get an false-Return in the isValid()-Function on the Layer and the Layer doesn't show up.
I ...
4
votes
1
answer
2k
views
PyQGIS reload a QGIS plugin
I have a plugin that has a psycopg2 connection to a PostGIS database. When i close GUI with the X-Button and open it again, all the widgets are filled with the data from before. It looks like the X is ...
4
votes
2
answers
723
views
Is it possible to customize openFeatureForm of PyQGIS?
I am a beginner at PyQGIS.
I am trying to create a plugin, which will be used to Add, Delete, and Edit the Feature.
It is more customized than which is provided by QGIS (2.2).
I am capturing the ...