Questions tagged [pyqt4]

python bindings for Qt4

Filter by
Sorted by
Tagged with
0
votes
0answers
46 views

Connecting to an SQLite database selected from a combobox

I selected a database from a combobox. And I want to connect to it so that I can create tables in it using PyQt. I think I should use the currentIndex, but I can't figure out how to do it. I saw that ...
0
votes
1answer
82 views

How to display table content using Qtableview after selecting a vector layer in Pyqt4?

I'm developing a QGIS plugin using QtDesigner and pyqt4. I have a comboBox of my vector layers and I want to show the table of the selected layer. I used this code for my comboBox: def run(self): ...
2
votes
0answers
54 views

How to make buttons work from second window in my QGIS plugin?

I'm trying to develop a QGIS plugin. I already created a second window. In that second window, there are several buttons that I need them to work. I can't say I'm a programmer that's why I don't ...
2
votes
1answer
773 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
89 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
0answers
78 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
1answer
463 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 ...
1
vote
0answers
39 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
1answer
183 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
0answers
20 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, ...
2
votes
2answers
591 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
346 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
0answers
79 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 ...
2
votes
1answer
565 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 ...
1
vote
0answers
96 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
39 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 ...
1
vote
1answer
863 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 ...
15
votes
1answer
784 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 ...
6
votes
1answer
539 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
64 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
1k 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
158 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
213 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
242 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
681 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
1k 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
597 views

Import Error: PyQt4 disabled by IPython, incompatible QT binding

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
174 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. ...
12
votes
3answers
6k 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'...
4
votes
2answers
19k 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
533 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 ...
8
votes
2answers
2k 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
769 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
95 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
56 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 ...
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 ...
1
vote
1answer
179 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
424 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
442 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
61 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
642 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
149 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
258 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
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 ...
2
votes
0answers
246 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
519 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
630 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
2k 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
603 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/...