The Stack Overflow podcast is back! Listen to an interview with our new CEO.
13

Is the copy of Qt Designer that comes with QGIS integrated wtih the QGIS GUI in anyway (like the forms designer within ms-access is the the rest of ms-access)? No it's not. The Qt Designer can be embedded into other applications however I haven't looked into doing this for QGIS yet. Can I start Qt Designer from within QGIS or do I have to have to ...


11

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;%PATH% set PATH=%PATH%;%OSGEO4W_ROOT%\apps\qgis\bin @echo off call "%OSGEO4W_ROOT%\bin\o4w_env.bat" call "%OSGEO4W_ROOT%\bin\qt5_env.bat" call "%OSGEO4W_ROOT%\bin\...


9

kopi, QMessageBox, and similar convenience classes, allow for quick creation of standard dialogs, generally using static methods within their class. Creating custom buttons and Qt widgets requires making the Qt signal/slot connections between them, as per the desired GUI interaction for the purpose. When using QtDesigner and after the compilation of your ...


8

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 internally, create your own repository, and share with who you want. But note that whoever receives the code is allowed to pass it on by the terms of the GPL. ...


8

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 pyrcc4 -o resources_rc.py resources.qrc After that, if you look inside the plugin folder, you will notice a new .py file, the resources.py file that was just ...


8

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 range (nb_row): for col in range(nb_col): item = QTableWidgetItem(str(data[row][col])) qTable.setItem(row,col,item) qTable....


6

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/ and then an example of a progress bar can be obtained directly from the QGIS code (Processing core plugin) https://github.com/qgis/QGIS/blob/master/python/...


5

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 default value (0), a minimum (0), a maximum (100) and a step (0.5). These values can be easily edited in the code (in the BarWidget class). The messageBar pop ...


4

You need to edit the properties of yours fields Date and Time in QGIS. Go to the properties of your layer. Select the Fields tab. In the line of your field (date and time), click on Line edit. Select Date/Time. And then you can specify the format of your date or time -> it must be the same as defined in Qt Designer! If the properties are the same in your ...


4

I found a workaround. I deleted all the data from the combobox in QT Designer and I defined the edit widget in Layer Properties -> Fields as Value Map. There, I put the data which I want displayed and voila!


4

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.e. If the field name is photo call it photo) Put a new QLabel or QWebView inside the container. If there are multiple QLabels inside you can specify the ...


4

After hours of trying I found a solution. It was inspired by this post: http://nathanw.net/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/ It's not possible to link the attribute from the table with UI file directly. To display a photo in a custom form, the user needs an addtitional python script. Let's call it startForm.py . Its content is as ...


4

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: from plugin_dialog2 import pluginDialog2 Copy and paste the UI file and rename it as form2.ui (optionally, open it in Qt-Designer and change the windowTitle ...


4

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 (2016/2017). Ten years ago, when it was about moving applications from Qt3 to Qt4, a Qt3Support module has been introduced to ease the migration. However, ...


4

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://github.com/webgeodatavore/bivariate_legend/blob/master/Makefile uses pyrcc5 to build its resources.py (I just picked a random QGIS 3 plugin - perhaps you should ...


4

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 lines and make sure they are called before you try to use the dialog anywhere. Also check that the name matches the name of your dialog (probably something ...


4

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 values into it and then dock its Attribute table window. Create your style expression to get the values from the layer: WHEN "valdco" = attribute(get_feature('...


3

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 promote it to a new class: set QgsMapCanvas as class name and set qgis.gui as header file. The pyuic4 utility will take care of it. This is a very ...


3

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(self.myConnectMethod) @pyqtSlot(QgsVectorLayer) def myConnectMethod(self, layer) self.myDataDefinedButton.init(layer, .....) so the link between the 2 ...


3

If I understand you very well you can do an attribute table formatting using the following steps: Open you attribute table Use Conditional Formatting Rules Select the field the you want to apply the formatting rules from the drop-down list. In this example, I want to use a field name "Test" Select New Rule Select New expression, write the expression ...


3

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.append('C:/Path/to/my/folder') I think you can add as many folders as you want - just add more "sys.path.append" lines in your file if you want to add more than one ...


3

As a somewhat klugey solution, you can set project- or layer-level variables for the validation criteria. For a project-level variable, go to Project / Properties / Variables and use the + button to add a variable named valdco_for_blue or similar and set it to the desired value. The data override function syntax you refer to the variable using @...


2

First i would create a list of categories and a dictionary containing the categories and related specific material like self.cat_list = ['metal', 'stone', 'wood'] self.mat_dict = {'metal':['gold', 'iron', 'copper'], 'stone':['flint', 'granite', 'wackestone']} and so on. Consider you comboBoxes are self.comboBox_category and self.comboBox_mat ...


2

Found a way, basically you just need to specify the column when populating the QTableWidget (mentioned in comment): qTable = self.dockwidget.tableWidget data = [] group1 = root.findGroup('Group1') group2 = root.findGroup('Group2') for child in group1.children(): data.append(child.name()) for child in group2.children(): data.append(child.name()) ...


2

If you use the QDialogButtonBox, I'm afraid you cannot do what you want from QT Designer (at least I couldn't with a bit of research :D). According to the Qt docs, dialogs return either 0 or 1, so you need to specify the value by using custom code: In order to modify your dialog's close behavior, you can reimplement the functions accept(), reject() or ...


2

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 = root.findGroup('Other group') layers = [] for group in other_group.children(): for layer in group.children(): layerList = QgsMapLayerRegistry.instance()...


2

Try the Plugin Reloader plugin.


2

I've got it, after lots of trial and error. Not sure what I was doing wrong originally, really. Must have been missing something, somewhere. Controls can indeed be referenced using the normal 'dot' notation i.e. def handleBrowseButton(self): pth =os.path.normpath('E:') filter = "TXT (*.txt)" file_name = QtGui.QFileDialog() file_name.setFileMode(3) # 3=...


2

I wrote this code to accept a QLineEdit object so that I could connect this same function to multiple buttons and pass in the appropriate field that I wanted to have filled out. I connected it with: someButton.clicked.connect(selectFile(someQLineEditObject)) When you click the button, a dialog box opens and fills the QLineEdit with the path to the ...


2

I dont have the expertise to answer (or the reputation to post the link as a comment) but at this link https://nathanw.net/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/, Nathan Woodrow explain how it could be done (the colors part is near the bottom of the page). So it definitely could be done but I'am afraid it involve much Python....


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