Questions tagged [pyqt5]

Python bindings for Qt5

Filter by
Sorted by
Tagged with
13 votes
3 answers
7k views

Make QGIS python plugin for both versions 2.x and 3.x?

I am in the process of migrating a QGIS python plugin from QGIS 2 to QGIS 3, and browsing various resources. It's not clear if it's possible to have the plugin compatible with both versions or if it'...
sigeal's user avatar
  • 879
9 votes
2 answers
2k views

No custom widgets in Qt Designer for QGIS 3

There are no custom widgets in my "Qt Designer with QGIS 3.0.3 custom widgets". Is it a bug or I should somehow manually enable them?
Basile's user avatar
  • 3,543
9 votes
2 answers
5k views

QGIS 3 Get coordinates from mouse click

I am working on a small QGIS Python plugin and want to get the X/Y coordinates from a user click on the canvas. I have a small UI called from button in a toolbar. After filling the UI with information ...
Firefly's user avatar
  • 355
7 votes
2 answers
2k views

NameError: name 'QMessageBox' is not defined

When I'm loading a CSV into QGIS, I get this error code, see below. Does anyone know what this means? This also is an issue when I attempt to run NNJoin Plugin too. An error has occurred while ...
Joan Lee's user avatar
7 votes
4 answers
20k 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 ...
Lorenzo's user avatar
  • 1,085
7 votes
1 answer
524 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())) ...
user9962595's user avatar
7 votes
1 answer
237 views

GIF freezes when QGIS plugin runs

I have a QGIS plugin and would like to put loading GIF (spinner) somewhere in the Dialog Window. The problem is when I run the spinner with the following code and call next function, the spinner ...
Марина Лисниченко's user avatar
7 votes
0 answers
1k views

QGIS 3: Set custom project variables with input dialog

I am using QGIS 3.10.0 and Windows 10. I have a project where I want the user to define custom project variables. I want to make this user friendly, I don't want the user to need to open the project ...
Geert's user avatar
  • 143
6 votes
1 answer
162 views

PyQt signal when layer name is changed in PyQGIS

Use this when layers are added, deleted, or their order is changed. Can you get a signal when a layer name is changed? QgsProject.instance().legendLayersAdded.connect(self.polygonList) QgsProject....
Jihyun Kim's user avatar
6 votes
1 answer
1k views

Opening embedded canvas in new window with all layers

I am creating a standalone custom PyQGIS application and have some questions regarding canvas. I have read the cookbook: https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/canvas.html ...
Sean Ang's user avatar
  • 143
6 votes
1 answer
931 views

Using a custom UI for a QGIS processing algorithm script

In QGIS 2.x I have a PyQGIS script that utilises a custom form created in Qt Designer. I could simply call the form and connect a button to a function with the following: class MyWidget(QtGui.QWidget)...
firefly-orange's user avatar
6 votes
1 answer
1k views

Compatibility PyQt5 and PyQt4

I'm having some compatibility problems with PyQt5, as expected some of the scripts I wrote are not working. My biggest issues are with these two PyQt4 functions: layer.pendingFields() layer = ...
Furio's user avatar
  • 63
6 votes
0 answers
796 views

QGIS 3 Value Relation current_value() not working in custom ui form

I have a custom UI form made with Qt Designer with a couple of dropdown list, so I can easily edit a layer. I use a Value Relation on those fields to filter the displayed data. The problem is the ...
Daniel's user avatar
  • 61
5 votes
1 answer
499 views

Getting point geometry by clicking at the map within QGIS plugin

From QGIS 3 Plugin Tutorial I need the example for getting a point geometry from clicking at the map. So I have a file point_tool.py: from qgis.gui import QgsMapTool, QgsMapToolEmitPoint from PyQt5....
Frau Schmidt's user avatar
  • 1,181
5 votes
1 answer
520 views

How to put QgsCheckableComboBox() into standby

I'm trying QgsCheckableComboBox() in my simple python script in QGIS. How to pause code execution while a comboBox-window is open (like a dialog box)? In my example, I want to ensure that the print() ...
user13892757's user avatar
5 votes
1 answer
2k views

How to use all QGIS 3 custom widgets in Qt Designer?

For example, QGIS 3.4 has various custom widgets such as QgsFieldValuesLineEdit and QgsColorWheel (and later versions have even more widgets) but they are not listed in the QGIS custom widgets list of ...
Orienteerix's user avatar
5 votes
0 answers
151 views

PyQGIS: What objects need to be destroyed in a custom expression

I'm using a custom (PyQGIS) function in expressions to make little detailed minimaps around each feature in a layer, and store it in the layer (gpkg) as a png. My code works but makes QGIS (3.12) ...
Houska's user avatar
  • 7,948
4 votes
1 answer
10k views

QGIS ImportError: No module named 'PyQt5.QtSvg'

Recently, I've installed QGIS 2.99 on my new Ubuntu 16.04 LTS desktop: sudo gedit /etc/apt/sources.list deb http://qgis.org/debian-nightly xenial main deb-src http://qgis.org/debian-nightly xenial ...
eclipsed_by_the_moon's user avatar
4 votes
1 answer
281 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
  • 517
4 votes
1 answer
1k views

How to get the selected value in a value map with Function Editor in QGIS 3.0.2?

I'm trying to automatically ("on-the-fly") add values to a value map widget depending on the value selected from another value map widget by using the Function editor in Expression dialog in the Layer ...
9ls1's user avatar
  • 1,397
4 votes
2 answers
1k views

"Couldn't load PyQt" While starting QGIS 3.0

The following error shows when I am trying to open QGIS 3.0. Although I have installed PyQt5 and the module can be imported from python. I am using Ubuntu 16.04 LTS
raosaeedali's user avatar
4 votes
1 answer
390 views

QgsFileWidget mandatory field in QWizard issue

I'm trying to create a mandatory QgsFileWidget in a QWizard form for a plugin but the result is a Next button that doesn't get active when I choose the path to save the project. Here is the snippet of ...
Marcelo Franco Patané Júnior's user avatar
4 votes
1 answer
394 views

Export theme and its associated layers in xml file in PyQGIS

I was trying to export all themes and its corresponding layers information through PyQGIS so that xml can be read later .There is method in Class: QgsMapThemeCollection, writeXml(self, doc: ...
Devenepali's user avatar
4 votes
2 answers
500 views

Showing dialog box even though QGIS is freezing

I have a long script in PyQGIS that contains three processing tasks after another. I want to display a pop up box (like "QProgressDialog"-Box) for each task when it is finished. Example: ...
POGO's user avatar
  • 294
4 votes
1 answer
450 views

QGIS configuration: Import Style Libary

I would like to script QGIS to import a style library as part as a configuration for a new user. By Python commands, how do I instruct QGIS to do what a QGIS user can do with the "Import Items" ...
Philip Whitten's user avatar
4 votes
1 answer
1k views

TypeError: qRegisterResourceData(int, bytes, bytes, bytes): argument 2 has unexpected type 'str'

Similar question here, I tried the suggested answer but it didn't work for my situation. updating plugin from qgis 2 to 3. qRegisterResourceData . argument 2 has unexpected type 'str' I am ...
MrKingsley's user avatar
  • 1,443
4 votes
1 answer
461 views

QGisPlugin : Trigger closeEvent by clicking 'X' in QgsAttributeForm

This is the code: def formOpen(dialog, layer, feature): """Function called when a connec is identified in the map""" global feature_dialog # Create class to ...
ncica's user avatar
  • 902
4 votes
0 answers
113 views

Restore default signals to QgsVectorLayer using PyQGIS

I have a connected a function to the QgsVectorLayer.selectionChanged signal of one of my layers. For the sake of simplicity let's assume it is a simple print statement: def print_confirmation(): ...
Matt's user avatar
  • 16.2k
3 votes
2 answers
715 views

Counting seconds using QTimer in PyQGIS [closed]

I am having a hard time counting seconds in PyQGIS using QTimer. The current code waits for 1 second and prints 5 times "1" as output. I desire that after every second the output should be ...
Sajeel Zafar's user avatar
3 votes
3 answers
2k views

Check if button is pressed in QGIS 3 module

There is a plugin I wrote for QGIS and I added some buttons there. From main launch Python script I need to check is specific button is clicked and according to that do some stuff. I saw a default ...
Pavel Pereverzev's user avatar
3 votes
1 answer
2k views

Developing QGIS plugin: AttributeError: object has no attribute

I was tasked with making a small plugin for QGIS or add a small functionality to an existing one. What I am trying to do is take the "geocode with web service" from the plugin MMQGIS and add ...
qgisStruggler's user avatar
3 votes
1 answer
369 views

Connect QgsMapLayerComboBox to QgsFieldComboBox and get text inputs

I've used the Plugin Builder tool to create the template python code. In QT Designer I have added a QgsMapLayerComboBox and QgsFieldComboBox I have gone through a couple of tutorials and checked the ...
GeorgeC's user avatar
  • 8,196
3 votes
1 answer
980 views

PyQT progress bar freezing

I create a progress bar using the code below on the QGIS console. However, the bar freezes in the beginning, doesn't increase at all, and suddenly appears as 100% in the end. What could be the reason ...
Melanie's user avatar
  • 159
3 votes
1 answer
279 views

Efficient filtering of many options in QGIS Plugin

Using PyQGIS, I am developing a QGIS plugin that includes a filter function. It should make handling easier for users (internal) who rarely use QGIS. Now I have created a interface with the QT ...
cc_schr_gis's user avatar
3 votes
2 answers
2k views

Ok Button disabled until every input has been filled

I'm developping a QGIS Plugin where the User clicks on the map, my plugin make a buffer and propose a street name, a street side and a disctrict, then the user selects which administration he's from ...
Svhooren's user avatar
  • 457
3 votes
2 answers
1k views

How to open and add SQLite connection to browser with PyQgis

I have a code to open the layers of a SQLite database. When executing this code, the layers are loaded correctly (1 & 2). However i also need to connect to the database and show the connection in ...
BearHunt's user avatar
  • 459
3 votes
1 answer
69 views

AttributeError when creating list field with QVariant in QgsVectorLayer using PyQGIS

I am trying to create a list-type field for the active layer using the code below, which is not working. Is there any other way to create a list-type field and update the list([1,2,3]) as an attribute ...
Ganesh S's user avatar
3 votes
1 answer
727 views

QGIS plugin closing all open PyQt dialogs

In my QGIS3 plugin I need to close all open PyQt5 dialogs. The structure of my plugin is like the following code. To be clear, when I call runCloseDialogs() I want to close both dialogs opened by run()...
Lorenzo's user avatar
  • 1,085
3 votes
1 answer
1k views

Using QCompleter with strings composed by different words in QGIS Plugin - PyQT5

I'm using QCompleter in my QGIS plugin. The code below works well, but I'd love to make it more sophisticated. In this example I have some strings that are composed of some words, for example "How to ...
Lorenzo's user avatar
  • 1,085
3 votes
1 answer
806 views

TypeError: QgsGeometry.fromMultiPolygonXY(): argument 1 has unexpected type 'list'

When I modify the code (which works) from: vertices = fProject.geometry().asMultiPolygon() for v in vertices: points.append(v) fet.setGeometry(QgsGeometry.fromMultiPolygonXY(points)) to: pt = ...
abhijeet pillai's user avatar
3 votes
1 answer
589 views

Remove parts of QGIS 3 toolbars using PyQGIS

How can I remove specific parts of QGIS toolbar? I know I can remove toolbars using this line of code: iface.fileToolBar().setVisible(False) But what I want is to delete every icon in the ...
DrJacoby's user avatar
  • 781
3 votes
1 answer
1k views

Check if PYQT5 Widget is Visible in QGIS Plugin

I'm trying to check if my widget is alredy open/visible before showing it (or before run this function). I need to check this because in my QGIS plugin it can happen that I call this function many ...
Lorenzo's user avatar
  • 1,085
3 votes
1 answer
769 views

PyQt5: QFileDialog triggered as many times as plugin is opened

I am new to QGIS and I'm building a plugin on it. The problem I'm facing, I believe, concerns mostly PyQt5. So, in my plugin I'm trying to open a file through getOpenFileName() of QFileDialog. I ...
Yashdeep Singh Dahiya's user avatar
3 votes
1 answer
200 views

Docking QGIS Plugin

How to dock QGIS plugin window? I am trying self.iface.addDockWidget(Qt.RightDockWidgetArea, dlg) in run method of QGIS Plugin Implementation class, but the dialog keeps appearing as a floating ...
Kubson's user avatar
  • 602
3 votes
1 answer
248 views

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

Since using the new installer for the x64 only version OSGeo4W/QGIS (new 3.22 LTR), I can't no longer use PyScripter with the bundled PyQt5. When I try to import QSettings for example, PyScripter can'...
Andreas Müller's user avatar
3 votes
1 answer
736 views

How to show the attribute table inside the dialogue of a custom plugin with QGIS

I need to create a custom table attribute inside a plugin where I can choose which layer I need to open and add new custom buttons to this custom table attribute To become like this :
lackti's user avatar
  • 31
3 votes
1 answer
804 views

Dynamic parameters in Qt Designer

Started building my first plugin in qgis and looking for a way to create dynamic widget in pyqyt and Qt designer which allow user to add or delete parameters as much as he want (something like a '+' ...
GallPeters's user avatar
3 votes
3 answers
861 views

Access icons from within QGIS plugin with relative paths?

I have constructed a QGIS plugin using QGIS Plugin Builder 3.0.3. Within my plugin, I need to load a .png file as a Qicon object. What needs to be done for the plugin script to locate the .png file ...
Philip Whitten's user avatar
3 votes
1 answer
1k views

Create a video from a track (GPX / KML) using Google Street View images

I am trying to create a video from a track in GPX or KML format from Google Street view images. If I enter the data of the coordinates of a location, I can generate a JPG with that image. My problem ...
RBenet's user avatar
  • 770
3 votes
1 answer
747 views

ERROR IN processing.run('qgis:countpointsinpolygon',XXX)

When I tried to write a python script to run Count points in polygon (https://docs.qgis.org/2.8/en/docs/user_manual/processing_algs/qgis/vector_analysis_tools/countpointsinpolygon.html) in QGIS, I ...
rui jiang's user avatar
  • 143