Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pyqt4]

python bindings for Qt4

1
vote
1answer
54 views

Adding x,y labels in QGraphicsview using pyqt4? [closed]

Here is my sample program. When I need to draw a line for x axis and y label for y axis .so can any one help me how to add a line and labels to scene.i tried different ways but i didn't get the proper ...
11
votes
0answers
218 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 from which I would like to inform the user ...
0
votes
0answers
14 views

How to disable all actions to digitize in pyQGis?

I'm trying to make a layer can not be edited, I already made a script that makes me disable my digitizing toolbar, but when I right click on the layer you can still make the editing commutation. How ...
6
votes
1answer
179 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(...
3
votes
0answers
47 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 ...
0
votes
1answer
142 views

QgsMapCanvas has no attribute 'setLayers'?

I would like to construct a GUI using PyQt4 and qgis outside of the main QGIS application. I found this tutorial which provides some indications on how to do this. I am looking to build something ...
0
votes
1answer
51 views

Using Stealth QDockWidget?

I'm playing with QDockWidgets. Here is the piece of code i'm trying : def dock(self): widget = uic.loadUi("C:\dock.ui") self.iface.addDockWidget(Qt.RightDockWidgetArea, widget) widget....
0
votes
1answer
2k views

Running Python produces 'No module named 'PyQt4' in Qgis on Mac High Sierra

I was following the instructions in this guide: Create a Polygon Shapefile from Point data and fairly sure I substituted field variables to match my data. However, when I run the script on my Mac (...
1
vote
1answer
86 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 ...
3
votes
1answer
117 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 ...
1
vote
0answers
471 views

ValueError: Attempted relative import in non-package

I run myscript and get this error: from qgis.core import * # @UnusedWildImport from qgis.gui import * # @UnusedWildImport from PyQt4.QtCore import * # @UnusedWildImport from PyQt4.QtGui import * # @...
0
votes
1answer
705 views

QGIS 2.18 ImportError: DLL load failed: The specified module could not be found

I try to run the QSwat script and it begins with that: from PyQt4.QtCore import * # @UnusedWildImport from PyQt4.QtGui import * # @UnusedWildImport from qgis.core import * # @UnusedWildImport from ...
1
vote
0answers
208 views

import error for qgis.core: PyQt4 disabled by IPython, incompatible QT binding, pyside, already imported

I'm running QGIS 2.14 and trying to learn how to develop python standalone scripts. Currently I am using Canopy's (v 2.1.3.3542) distribution of Python 2.7. My development is on a Mac (OS 10.13.1) ...
1
vote
0answers
94 views

Implementing signals on add feature with PyQGIS?

I'm trying to implement the code below to run when adding a feature in the layer, but nothing happens even an error message. However when I call the method directly, the routing is executed normally. ...
11
votes
3answers
2k 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'...
3
votes
2answers
4k 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" ...
2
votes
2answers
299 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 ...
7
votes
2answers
779 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 ...
3
votes
2answers
508 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 ...
1
vote
1answer
49 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 ...
2
votes
1answer
50 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 ...
0
votes
0answers
183 views

QGIS crashes on start up after installing PyQt4 on Ubuntu

I am running QGIS 2.14 (Essen) on Ubuntu 16.04. I installed QGIS via sudo apt-get install qgis. QGIS was running just fine, but I had issues running some plugins (the profile tool), which seemed to ...
3
votes
1answer
628 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 ...
1
vote
1answer
110 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 ...
2
votes
0answers
196 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 ...
3
votes
1answer
261 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. ...
1
vote
1answer
55 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 ...
3
votes
1answer
281 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 ...
2
votes
0answers
85 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
2answers
96 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....
1
vote
1answer
630 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 ...
2
votes
0answers
202 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,...
3
votes
1answer
364 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
1answer
458 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 ...
3
votes
1answer
754 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
326 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/...
1
vote
1answer
138 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
367 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: ...
2
votes
0answers
86 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 ...
9
votes
2answers
11k 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 "...
1
vote
1answer
176 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
205 views

pyQt error in the PYQGIS API

I install QGIS via OSGeo4W 32 bit on windows 7 32 bit and i want to take PYQGIS API in standalone python script. First I have python 3.5.2 and I have before install sip via pip and pyqt4 via gohlke ...
7
votes
1answer
511 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=...
2
votes
2answers
134 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
194 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 ...
2
votes
2answers
348 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....
4
votes
1answer
288 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 ...