Questions tagged [pyqt4]

python bindings for Qt4

Filter by
Sorted by
Tagged with
15
votes
1answer
576 views

Showing startup-messages on QGIS splashscreen

During the startup of QGIS, there are status messages shown in the lower part of the splashscreen like "restoring loaded plugins". I am using a startup.py feature from which I would like to inform ...
12
votes
3answers
5k 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'...
12
votes
3answers
19k views

No module named 'osgeo'

I have installed GDAL and checked on the command line, it is working and when I run the gdal2tiles.py on the command line it works but when I run the same file gdal2tiles.py with python IDLE, I get "...
7
votes
2answers
1k views

Get the identified feature

I use QgsMapToolIdentifyFeature to trap the featureIdentified signal, so i can get some information from the identified feature and show it in a panel within my plugin. here is the code, my problem ...
7
votes
1answer
744 views

Select and use raster layer from python

I'm a developer but this is the first experience with python and QGIS Plugin, I want make a plug-in for Remote Sensing Index. I have followed this basic tutorial https://www.youtube.com/watch?v=...
6
votes
1answer
328 views

Change background color of Layer in the TOC / QgsLayerTreeLayer with pyqgis

I would like to change the background-color (or font color) of some items in the TOC of QGIS: Example-Mockup: I tried several ways but nothing did the trick so far: layer_list = QgsProject.instance(...
4
votes
1answer
425 views

How to call a method when self.iface.actionSelectRectangle().trigger() is released?

In my QGIS python plugin I use self.iface.actionSelectRectangle().trigger() to select features. I also have a button which changes the attributes of the selected features. Is there a way instead of ...
3
votes
2answers
11k views

How to add a filter to “QFileDialog.getOpenFileName” [closed]

I would like to add a filter to the following code in order to select only the “CSV files”, but I did not succeed: def filePath(title): qfd = QFileDialog() path = "D:\ennine\SIG HTB\BGN" ...
3
votes
2answers
669 views

Plugin crashes QGIS 2.18 if running simuntaneously with python console

I'm currently developing plugin for QGIS 2.18. From the begining I'm having the same issue. QGIS 2.18 crashes if I run python console while plugin is working something. I saw that print statements ...
3
votes
1answer
1k views

Create a upload button in PyQt QGIS plugin

I want to create 2 upload file button in PyQt. One for image and one for .csv file. If the uploaded file is not in image or .csv file it should thrown an message. I have search a lot on internet and ...
3
votes
1answer
383 views

How to use processing in a PyQT plugin in QGis

I am writing a QGis plugin with UI that should utilize certain QGIS processing tools when the user runs the plugin. Now I tried a lot, searched a lot and came along quite many different approaches. ...
3
votes
1answer
1k views

Check if QLineEdit is NULL on a custom form?

I have a custom form with some validation. One these validation is if the value of attribute is NULL. The value of NULL representation on the QGIS is float according of the Configure->Options. How ...
3
votes
1answer
536 views

Rendering a custom bounding box to an image file using python and QGIS?

Edit: the problem was merely a typo in the coordinates (see comment on definition of p). Otherwise the code below should work for other situations, too, if adapted properly. The weird pixelated/grey/...
3
votes
1answer
181 views

How to monitor changes in layers panel for QGIS?

I'm writing Python script in QGIS 2.18 to alert the user when multiple layers with different projections are added to the canvas. My codes are shown below. from qgis.gui import QgsMessageBar ...
3
votes
1answer
459 views

QGIS plugin fields will not reset

I am new to PyQGIS and PyQT programming. I have built a small QGIS plugin, which uses the NetworkX library to do some processing of shapefiles. The form executes it's business logic correctly, but ...
3
votes
1answer
1k views

Python script for opening webpage directly in QGIS

I have a shapefile with points referring to a webpage with a photograph. Until now I define an action to open the corresponding webpage in firefox. Eg. I have to share my project. Because I don't ...
3
votes
0answers
61 views

How can I get real time log in .bat file at QGIS & PlugIn with Python PyQT4

I try to get real time log in batch file with python, then show it to QGIS Plugin real time. ( .bat file have run -jar file ) I success logging but not real time log in QGIS because QGIS is stopped ...
3
votes
1answer
465 views

Error inside pyinstaller app with pyqgis & pyqt4 on Windows

I am trying to generate a standalone exe using the pyqgis and related libraries. I have borrowed from the app in the book 'Building Map Applications with QGIS', by Erik Westra and published by PACKT. ...
2
votes
2answers
457 views

Keep track of current layers in PyQt plugin for QGIS

I have a QGIS plugin which has a combobox (QComboBox) element with a list of layers currently opened in QGIS. The problem is that the layer list is only updated on initialization of the plugin (I do ...
2
votes
1answer
582 views

error sip.setapi(api, 1) in pyQGIS

I have installed QGIS via osgeo4w 32 bit yesterday, to take pyqgis api in standalone script, but I have some problems. I have python 2.7.13 32bit and pyqt4 installed from Gohlke. After, I created a ...
2
votes
1answer
31 views

How to change the particular letter color in text box using python

I need to highlight the particular letter in a text box using python. I am using the below code but it changes the entire text color in text box. Kindly suggest any other ideas. I am ...
2
votes
1answer
58 views

Tableview with 2 columns

I'm using QlistView to show my names of departement in the studied area after using the 'extract by location' processus: # res=QgsVectorLayer() # capture département inside the studied area : ...
2
votes
1answer
130 views

How do I call the objects created with QtDesigner (or QtCreator) in my code in python? Where is this information in python? PyQt4 please

Where can I find a good documentation on how to refer (to call) to the Dialog created with QtDesigner? For example, a buttomBox (or any other) just created. I’m trying to make a plugin, but the ...
2
votes
1answer
224 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 ...
2
votes
1answer
53 views

Follow current line in attribute table?

I would like to teach the QGIS map canvas to follow the current row of an attribute table. I found the method QgsAttributeTableView.currentChanged() as possible starting point, but unfortunately it's ...
2
votes
2answers
191 views

Getting Error While Parsing Feature To The lineEdit In Python

am getting error while parsing a selected feature to the lineEdit like, QLineEdit.setText(QString): argument 1 has unexpected type 'long' layer = self.iface.activeLayer() h = layer....
2
votes
2answers
481 views

QGIS Network Analysis: QgsLineVectorLayerDirector.makeGraph(), attribute type QVector not available

relates to QGIS 2.14.6LTR on Win10, PyQt Version 4.10.2 When trying to makeGraph() on QgsLineVectorLayerDirector as described in the "QGIS Network analysis library" documentation (http://docs.qgis....
2
votes
0answers
67 views

How to capture the event whenever the items inside a listview are checked

I'm developing a plugin in QGIS 2.8.2 using Pyqt 4. Well the idea is using the processing 'qgis:extractbylocation' from the QGIS algorithm provider to capture the studied area # Récupérer tous les ...
2
votes
0answers
345 views

QTableWidget Resize with Dialogue Python QGIS

I am developing python qgis plugin with QTableWidget inside a tabWidget. How can i set my QTableWidget size and QTabwidget with the Dialogue box. So that when someone expand the dialogue box of the ...
2
votes
0answers
125 views

Error While Fetching Data From Postgres In Qgis Plugin

i am trying to fetch data from postgres in qgis and the connection code is working fine in python console but it gives error when i apply that code to my plugin like.. AttributeError: 'NoneType' ...
2
votes
0answers
232 views

QGIS Profile Tool dependencies

I'm trying to install the Profile Tool on QGIS 2.14 (newest version present in ubuntugis ppa) and i get this error:'No module named PyQt.QtCore' I have installed the following packages:python3-pyqt4,...
2
votes
0answers
149 views

Custom QDialog is blank in QGIS 2.8.3

I have a QGIS plugin for displaying feature data and I'm trying to make a custom dialog to prompt the user to change the id of the feature being saved if the id is already in use. For some reason ...
2
votes
2answers
157 views

Filter Layerlist in Snapping Options Dialog

I have some large QGIS-Projects where I would like to filter the layerlist that is used for the advanced snapping options. Even if there are a lot of layers used in the project I only have to adjust ...
2
votes
0answers
248 views

Automate print composition in QGIS

My goal is it to write a plugin, that automates the print composition. The idea is that you choose the scale and the paper size and based on that a map with legend, north arrow and block title is ...
1
vote
2answers
107 views

QGIS2 to QGIS3 plugin migration issue AttributeError: type object 'QObject' has no attribute 'connect' [duplicate]

I am trying to migrate a plugin. I have these two lines: QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Configuration.accept) QtCore.QObject.connect(self.buttonBox, ...
1
vote
1answer
77 views

How to display messages in the QGIS log from within a QTimer callback?

So I'm new to QGIS and Qt, and trying to write a simple toy python plugin. I'm trying to get the plugin to do "stuff" at regularly timed intervals, and to test, I'm just trying to get the script to ...
1
vote
1answer
524 views

Trigger plugin button using PyQGIS?

I wrote a project macro which, when loaded, hides all toolbars except for one which contains a couple of my plugin buttons. I know it's possible to trigger core buttons like the following example: ...
1
vote
1answer
71 views

How to get QGIS canvas in plugin window? [closed]

I'm working on project where I need insert QGIS canvas as a widget in QGIS plugin. When user click on button it should be loaded into widget. Something like this, this is example where satellite map ...
1
vote
1answer
68 views

Trying to find the Qt5 version of QVBoxLayout

Migrating a plugin and started getting the error AttributeError: module 'qgis.PyQt.QtGui' has no attribute 'QVBoxLayout' I cannot find this one in the API changes I tied using qgis.PyQt5.QtGui but ...
1
vote
1answer
154 views

Error Accessing Dockwidget ComboBox. QGIS Plugin. (pyqgis)

I'm writing a QGIS plugin but I'm facing some basic problems. The plugin is a dockwidget. I've built it with plugin Builder and then compiled the resources file. When I try to access the comboBox to ...
1
vote
1answer
143 views

QTest interactions with the QGIS Map canvas

Is it possible to simulate right or left mouse button clicks on a QGIS map canvas. Currently writing tests for a plugin and need to be able to create a line geometry thorough the use of theses ...
1
vote
1answer
57 views

Modifying the copy coords plugin

I want to modify the copy_coords plugin such that when I click on it, It should open a dialog box and ask for a file name and address. After this it should store all the points I click on into that ...
1
vote
1answer
1k views

Converting GeoTIFF file to numpy array to QPixmap with PyQt4?

I'm a student in CS doing an internship and I'm not familiar at all with GIS yet. I have to display a GeoTIFF image (with a single band) into a QPixmap with PyQt4. So, I found some code that could ...
1
vote
1answer
269 views

Displaying QGIS plugin icons without resources.py file?

I am working on a new QGIS plugin and I am trying to comply with the requirement below. The full requirement is located here. source repository is in good shape: no generated file is ...
1
vote
1answer
240 views

Read Sld Style in pyQGIS

I am trying to set a layer's style using pyQGIS. My primary idea was to set the style from a string, but unfortunately I can only do it from a file. This code works as a charm: filename= QDir....
1
vote
0answers
33 views

Blank MapCanvas Window [closed]

I am constructing a GUI using PyQT4 and QGis. Rigth now I can open the MapCanvas whith same buttons of Zoom In/Out using this code: from qgis.gui import * from qgis.core import * from qgis.PyQt.QtGui ...
1
vote
0answers
18 views

Replicating the Layers Panel in my app, with sub-layers [closed]

I've followed this post, using the QGIS Desktop Python Console, to create color ranges for my vector layer. QGIS displays a nice selectable tree in the Layers Panel. Now I want to develop my own app, ...
1
vote
0answers
57 views

How to find which direction to flow between two points in QGIS Python? [closed]

I want to find which way direction to go based on two points and line segment. I have two layer line layer and point layer.user selects the two points in lines layer. I have to find which direction to ...
1
vote
0answers
60 views

QGIS 2.18 - Can't get click coordinates from mapCanvas

Trying to get click coordinates from map canvas but code is not working. Newbie for Python, pyqgis, pyqt I already check these topics but still code is NOT working 1 - QGIS 3 Get coordinates from ...
1
vote
0answers
33 views

Resizing QGIS custom form

I have followed this tutorial to create custom forms in QGIS (I work with version 2.18). However, I seem to be unable to control the shape and size of the form window. Thus, widgets are frequently out ...