Questions tagged [pyqt]

PyQt is a set of Python v2 and v3 bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, macOS, Linux, iOS and Android

PyQt Components

PyQt4 contains the following Python modules.

  • The QtCore module contains the core non-GUI classes, including the event loop and Qt's signal and slot mechanism. It also includes platform independent abstractions for Unicode, threads, mapped files, shared memory, regular expressions, and user and application settings

  • The QtGui module contains the majority of the GUI classes. These include a number of table, tree and list classes based on the model-view-controller design pattern. Also provided is a sophisticated 2D canvas widget capable of storing thousands of items including ordinary widgets.

  • The QtHelp module contains classes for creating and viewing searchable documentation and being able to integrate online help with PyQt applications. It is based on the C++ port of the Lucene text search engine.

  • The QtNetwork module contains classes for writing UDP and TCP clients and servers. It includes classes that implement FTP and HTTP clients and support DNS lookups. Network events are integrated with the event loop making it very easy to develop networked applications. The QtOpenGL module contains classes that enable the use of OpenGL in rendering 3D graphics in PyQt applications.

  • The QtScript module contains classes that enable PyQt applications to be scripted using Qt's JavaScript interpreter.

  • The QtSql module contains classes that integrate with open-source and proprietary SQL databases. It includes editable data models for database tables that can be used with GUI classes. It also includes an implementation of SQLite.

  • The QtSvg module contains classes for displaying the contents of SVG files. It supports the static features of SVG 1.2 Tiny.

  • The QtTest module contains functions that enable unit testing of PyQt applications. PyQt does not implement the complete Qt unit test framework. Instead it assumes that the standard Python unit test framework will be used and implements those functions that simulate a user interacting with a GUI.

  • The QtWebKit module implements a web browser engine based on the WebKit open source browser engine used by Apple's Safari. It allows the methods and properties of Python objects to be published and appear as JavaScript objects to scripts embedded in HTML pages.

  • The QtXml module implements SAX and DOM interfaces to Qt's XML parser.

  • The QtXmlPatterns module implements XQuery and XPath support for XML and custom data models.

  • The phonon module implements a multimedia framework that enables the use of audio and video content in PyQt applications. On Windows DirectX is used as the backend, on MacOS/X QuickTime is used as the backend, and on Linux GStreamer is used as the backend.

  • The QtMultimedia module implements low-level multimedia functionality. Application developers would normally use the phonon module.

  • The QtAssistant module implements a simple interface for integrating Qt Assistant with PyQt applications to provide online help. Qt Assistant is itself implemented using QtHelp.

  • The QtDesigner module contains classes that allow Qt Designer to be extended using PyQt.

  • The QAxContainer module implements access to ActiveX controls and COM objects. It is only available in the commercial version of PyQt for Windows.

  • The Qt module consolidates the classes contained in all of the modules described above into a single module. This has the advantage that you don't have to worry about which underlying module contains a particular class. It has the disadvantage that it loads the whole of the Qt framework, thereby increasing the memory footprint of an application. Whether you use this consolidated module, or the individual component modules is down to personal taste.

  • The DBus support module is installed as dbus.mainloop.qt. PyQt does not support Qt's native DBus classes. Instead the module enables the Qt event loop to be used with the standard DBus Python bindings. It is only available for PyQt for X11.

  • The uic module implements support for handling the XML files created by Qt Designer that describe the whole or part of a graphical user interface. It includes classes that load an XML file and render it directly, and classes that generate Python code from an XML file for later execution.

PyQt Documentation

Current documentation is available for PyQt4 and PyQt5.

Books about PyQt

A list of tutorials

IDE for PYQT

16996 questions
18
votes
3 answers

PyQt vs PySide comparison

I currently develop many applications in a Qt heavy C++/Python environment on Linux, porting to PC/Mac as needed. I use Python embedded in C++ as well as in a stand alone GUI. Qt is used fro xml parsing/event handling/GUI/threading and much more.…
cmaynard
  • 2,852
  • 2
  • 24
  • 34
18
votes
8 answers

PyQt4 center window on active screen

How I can center window on active screen but not on general screen? This code moves window to center on general screen, not active screen: import sys from PyQt4 import QtGui class MainWindow(QtGui.QWidget): def __init__(self): …
Applejohn
  • 315
  • 1
  • 2
  • 5
18
votes
4 answers

PyQt - Implement a QAbstractTableModel for display in QTableView

I would like to display a pandas data frame in a PyQt table. I have made some progress with this, but have not been able to correctly derive the Table Model class. Any help with this would be much appreciated. ** Note full example code here ** I am…
C Mars
  • 2,909
  • 4
  • 21
  • 30
18
votes
2 answers

Plotting large arrays in pyqtgraph

For an electrophysiology data analysis set I need to plot a large 2D array (dim approx 20.000 x 120) of points. I used to embed a Matplotlib widget in my PyQt application, but went looking for other solutions because the plotting took quite long.…
jw_p
  • 325
  • 1
  • 3
  • 7
18
votes
4 answers

PyQT GUI Testing

Does anyone know of a automated GUI testing package for that works with PyQT besides Squish? Nothing against Squish I am just looking for other packages. It would be cool if there were an open source package. I am doing my testing under Linux.
Paul Hildebrandt
  • 2,724
  • 28
  • 26
18
votes
4 answers

How to create filters for QTableView in PyQt

I am using QTableView to display data retrieved from QtSql.QSqlQuery I want to know how can i create filters for it like in excel. In the above image i need to get the filters for All heders (Sh_Code,SH_Seq,Stage) The filters will have unique…
Rao
  • 2,902
  • 14
  • 52
  • 70
18
votes
4 answers

How to create QString in PyQt4?

>>> from PyQt4 import QtCore >>> str = QtCore.QString('Hello') AttributeError: 'module' object has no attribute 'QString' >>> QtCore.QString._init_(self) AttributeError: 'module' object has no attribute 'QString' Yes, I've read QString Class…
beta-closed
  • 295
  • 1
  • 3
  • 10
17
votes
1 answer

Adding items to QlistView

I'm using pyqt4 with python 2.7 and I have a list view widget that I can't add items to it # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'add_category.ui' # # Created: Mon Mar 19 23:22:30 2018 # by: PyQt4 UI…
Ahmed Wagdi
  • 3,913
  • 10
  • 50
  • 116
17
votes
1 answer

function of pyqtSlot

I just read a tutorial about pyqt5 button from here. And the code is as below. There is a question about button.clicked.connect(self.on_click) and @pyqtSlot(). If I delete @pyqtSlot() from the code, it still works. However, the button does not work…
Kester
  • 283
  • 2
  • 5
  • 10
17
votes
0 answers

Using PyQt for Front End Web Development

I have written a single-script (i.e. full-stack) GUI in PyQT which queries an SQL database, performs some functions with the query outputs and then displays these outputs graphically in a QtGui.QApplication. However, I have decided that I would like…
Sadie LaBounty
  • 379
  • 1
  • 5
  • 23
17
votes
1 answer

How to connect pyqtSignal between classes in PyQT

How to connect pyqtSignal between two different objects (classes) PROPERLY? I mean best practice. Look what I have done to achieve the goal: The Thermometer class is notified when Pot increases its temperature: from PyQt4 import QtCore class…
Ondrej Vencovsky
  • 3,188
  • 9
  • 28
  • 34
17
votes
2 answers

PyQt QTableView Set Horizontal & Vertical Header Labels

using QTableWidget i can do table = QTableWidget() table.setHorizontalHeaderLabels(QString("Name;Age;Sex;Add").split(";")) table.horizontalHeaderItem().setTextAlignment(Qt.AlignHCenter) how can i do same with QTableView ??
Ruchit
  • 661
  • 1
  • 6
  • 19
17
votes
1 answer

Capture the "Save your changes" dialog when using win32gui and closing an embedded application within a QApplication?

I am embedding an application within a tab in a pyqt QApplication. When I close the tab this application is embedded in how do I allow it to display the "Save your changes" dialog? I use this on…
Andy
  • 49,085
  • 60
  • 166
  • 233
17
votes
1 answer

PyQt: How to reset the cursor to whatever it's hovering over

Very small issue: I've written a small IDE with a text editing widget based on a QPlainTextEdit. When you move the mouse over it the cursor becomes a caret/text cursor as expected. If you hit F5 the window is disabled and a small script runs after…
Michael Clerx
  • 2,928
  • 2
  • 33
  • 47
17
votes
2 answers

Using sys.exit() with app.exec_ in pyqt

Can anyone explain the relative merits of using sys.exit(app.exec_()) rather than the simpler app.exec_() to start a GUI in PyQt? I am new to PyQt and have seen both examples.
user3616508
  • 183
  • 1
  • 1
  • 5