16 votes

How can I add a second Toolbar Button and Dialog to a QGIS plugin built with Plugin Builder?

1. Use Plugin builder to create a new plugin The files created are shown in the following picture 2. Convert the resources file (resources.qrc) to Python file (resources.py) using the OSGeo4W Shell ...
Eleftheria's user avatar
12 votes
Accepted

How to compile QtDesigner user interface (.ui) and resource (.qrc) files with QGIS 3 on Windows?

You need set PyQT5 environments. This is my scripts for compile QGIS 3 Plugins and have 3 complementary bats. compile_ui.bat @ECHO OFF set OSGEO4W_ROOT=D:\OSGeo4W64 set PATH=%OSGEO4W_ROOT%\bin;%...
Fran Raga's user avatar
  • 7,780
8 votes
Accepted

How to populate QTableWidget via plugin?

Let me share how it works for me: self.setWindowTitle(title) #data = 'Recordset back from postgis' nb_row = len(data) nb_col = 2 qTable.setRowCount(nb_row) qTable.setColumnCount(nb_col) for row in ...
WKT's user avatar
  • 2,183
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 ...
Alexandre Neto's user avatar
8 votes

Target a specific attribute table

Below a code with a simple QDialog with 2 comboBoxes (specialized for QGIS to display layers and fields) : class MyDialog(QDialog): def __init__(self, parent=None): super(MyDialog, self)....
J. Monticolo's user avatar
  • 15.6k
7 votes
Accepted

How can I add a second Toolbar Button and Dialog to a QGIS plugin built with Plugin Builder?

Here's what I did to implement a second Toolbar button and its corresponding dialog: Edit the plugin.py file to add a run2() method, a self.dlg2 variable, a new action in initGui(), and this import: ...
Germán Carrillo's user avatar
7 votes
Accepted

Getting directory path from QgsFileWidget using PyQGIS

Plugin Builder adds a method named run to the plugin.py. You can implement the script below with a little editing. I assume you have set storageMode to QgsFileWidget.StorageMode.GetDirectory for ...
Kadir Şahbaz's user avatar
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/ ...
Luigi Pirelli's user avatar
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' ...
xunilk's user avatar
  • 29.5k
6 votes
Accepted

Embbeding QgsLayoutDesignerInterface in plugin widget using QtDesigner and PyQGIS

Based on this quote from your question: My goal is to simply display (no edit settings needed) a map layout in a plugin widget as soon as the related map is chosen from a combobox . My guess is that ...
Ben W's user avatar
  • 20.2k
6 votes
Accepted

Connecting signals to different functions based on combobox selection

Instead of making individual connections for each combobox options, it is more reasonable to connect the button click event to one function which checks the combobox value and calls the related ...
Kadir Şahbaz's user avatar
5 votes

QtDesigner add map canvas widget

Just choose a QWidget and promote it. From PYQGIS official guide: It can be also embedded into an existing widget or window. When using .ui files and Qt Designer, place a QWidget on the form and ...
dmh126's user avatar
  • 6,622
5 votes

Python GUI for QGIS plugin ; 'ModuleNotFoundError: No module named...'

Is there a file called resources.py? This is probably generated from a resources.qrc file by a rule in your Makefile, if that tries to use pyrcc4 it will fail on QGIS 3 because it uses Qt 5. https://...
Spacedman's user avatar
  • 61.6k
5 votes

No custom widgets in Qt Designer for QGIS 3

In QGIS 3.2.0, custom widgets seem to be available: Tested on Windows 7 64-bit. Edit: I used the QGIS Standalone Installer Version 3.2 (64 bit) and following the simple on-screen instructions. Once ...
Joseph's user avatar
  • 75k
5 votes
Accepted

No custom widgets in Qt Designer for QGIS 3

The environment and path needs to be set for Qt Designer to access the QGIS Custom widgets. These can be set by running the "qgis-designer.bat" file that comes with a QGIS installation. For a ...
Philip Whitten's user avatar
5 votes
Accepted

Making Upload button for shapefile in QGIS plugin?

If you look at step 23 in the tutorial you'll see some lines in the run method: if self.first_start == True: self.first_start = False self.dlg = SaveAttributeDialog() You need to find those ...
Ian Turton's user avatar
  • 79.9k
5 votes
Accepted

Manipulating value with toolbar

I've coded a simple QgsMessageBar which contains a widget with 3 double-spinbox (and their labels), and a QPushButton for load colors. One for each color (Blue, Orange and Red). Each SpinBox have a ...
J. Monticolo's user avatar
  • 15.6k
5 votes

Qt Designer forms and QGIS

You can link a ui file directly to a table under Properties > Attribute Form, and select Provide ui-file from the top combobox. You can dynamically load a ui to a Python class inheriting from ...
Jakob's user avatar
  • 7,451
5 votes

Qt Designer forms and QGIS

I designed a sample form in QtDesigner. Here is the form which contains one button: In QGIS Python Console or Editor, Load this form using uic.loadUi. Define a method. Connect this method to the ...
Kadir Şahbaz's user avatar
5 votes
Accepted

PyQT plugin window is always smaller than when run in QGIS

Simply dragging and dropping widgets onto a dialog in Qt Designer is a quick way to get a working ui, but it does not in any way guarantee consistent appearance. To demonstrate this, I created a dummy ...
Ben W's user avatar
  • 20.2k
4 votes
Accepted

How to connect QgsMapLayerComboBox to QgsDataDefinedButton

Thanks to the qgis-dev mailing list and to Denis Rouzaud, this is the answer.. class MyDialogClass(UiClass): def __init__(self): self.setupUi() self.myLayerComboBox.layerChanged.connect(...
matteo's user avatar
  • 3,244
4 votes

How to display a picture in QGIS custom form?

The solution which does not require python is In QtDesigner Add a new QWidget (or any other widget which serves as a container) and in the properties set the objectName to match the field's name. (I....
Matthias Kuhn's user avatar
4 votes
Accepted

How to use Qt3 Support widgets in QGIS plugin?

The widgets which you are referring to are leftovers from Qt3. QGIS at the moment is based on Qt4 (which exists since 2005 and has seen end of life in December 2015) and is soon to be updated to Qt5 (...
Matthias Kuhn's user avatar
4 votes
Accepted

How to filter out layers with QgsMapLayerComboBox?

Guess it was easier than I thought, I just had to create a list of QgsMapLayers from a group I want excluded in the QgsMapLayerComboBox: root = QgsProject.instance().layerTreeRoot() other_group = ...
Joseph's user avatar
  • 75k
4 votes
Accepted

QGIS 2.18 : Choosing path of file for Python init function

I found a solution - don't know if it's the best one, but it's fine by me. I added a startup.py file in the .qgis2/python folder. This file must contain the following lines: import sys sys.path....
Mefimefi's user avatar
  • 586
4 votes
Accepted

Python GUI for QGIS plugin ; 'ModuleNotFoundError: No module named...'

In your case you need to use relative path instead of absolute path. Assuming that ais is present in same directory as main.py you need to change from ais import AISForm to from .ais import ...
Asad Abbas's user avatar
  • 1,634
4 votes
Accepted

How to get QGIS canvas in plugin window?

In QT designer you need make right click on the widget and select "promote to", and write the class and header as seen in the image. after you need compile the .ui. In the class that loads this ui, ...
Fran Raga's user avatar
  • 7,780
4 votes

Manipulating value with toolbar

You want to style your layer based on three values and you want a quick way to change those values. One way to get something close would be to create a layer with no geometry and put the three ...
M Bain's user avatar
  • 1,907
4 votes
Accepted

Image Adding Problem to QGIS Plugin GUI with Qt Designer

I found a solution with the help of this post. It worked for me. I'm on QGis 3.16, I hope it's the same for the 3.10 version. Once you've added the resource image. You need to open the file ...
JULESG's user avatar
  • 1,597
4 votes

QgsFileWidget mandatory field in QWizard issue

Try to pass the third parameter as string which refers property name, filePath here. self.wizardPage.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged) Here is a working ...
Kadir Şahbaz's user avatar

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