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
58
votes
13 answers

Convert pyQt UI to python

Is there a way to convert a ui formed with qtDesigner to a python version to use without having an extra file? I'm using Maya for this UI, and converting this UI file to a readable python version to implement would be really great!
Shannon Hochkins
  • 11,763
  • 15
  • 62
  • 95
57
votes
3 answers

Detecting enter on a QLineEdit or QPushButton

I've built an app for a game, simple to start. It's a game in which the system randomly chooses a number and a gamer (player) tries to find out the number. Everything is almost done. The app consists of a QLineEdit, a label and three buttons. Once…
arkero24
  • 669
  • 1
  • 5
  • 7
54
votes
4 answers

How do I plot only a table in Matplotlib?

Is it possible to draw only a table with matplotlib? If I uncomment the line plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row]) of this example code, the plot is still visible. I want to have a table on top of my (PyQt)…
honeymoon
  • 2,400
  • 5
  • 34
  • 43
51
votes
2 answers

pyqt: how to remove a widget?

I have a QGroupBox widget with children in it that I want to remove. How do I do that? I can't find any removeWidget, removeChild, removeItem, or anything similar in the docs. I can only see how to remove things from a layout, but that, apparently,…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
50
votes
3 answers

Is the PySide Slot Decorator Necessary?

I've seen some example code for PySide slots that uses the @QtCore.Slot decorator, and some that does not. Testing it myself, it doesn't seem to make a difference. Is there a reason I should or should not use it? For example, in the following…
JasonFruit
  • 7,764
  • 5
  • 46
  • 61
48
votes
5 answers

Qt programming: More productive in Python or C++?

Trying to dive into Qt big time but haven't done a large project with it yet. Currently using Python, but I've been thinking -- which is really the better language to use in terms of programmer productivity? In most comparisons between the…
Micah Yoder
  • 695
  • 1
  • 5
  • 8
47
votes
3 answers

wxPython vs PyQt vs PyGTK: when and what to use?

Need advise from those who have minimum health experience to design GUI interfaces with Python. When and what to choose depending of GUI complexity? Which GUI builders can we use to have a better development quality? This is my first GUI design,…
user1630938
46
votes
9 answers

Quick and easy: trayicon with python?

I'd just need a quick example on how to easily put an icon with python on my systray. This means: I run the program, no window shows up, just a tray icon (I've got a png file) shows up in the systray and when I right-click on it a menu appears with…
Marco Moschettini
  • 1,555
  • 2
  • 16
  • 26
46
votes
6 answers

Dark theme for Qt widgets?

Background I'm building a PyQt5 application, that I'd like to have a dark theme for. Previously I've worked with Android development where there was a dark theme that I could set for a whole application Question Is there a dark theme built into Qt…
sunyata
  • 1,843
  • 5
  • 27
  • 41
46
votes
2 answers

PyQt on Android

I'm working on PyQt now, and I have to create the application on Android, I've seen the kivy library, but it's too crude. Is there any way now to run an application on Android made on PyQt?
cyberbudy
  • 732
  • 1
  • 6
  • 19
45
votes
4 answers

How do you get the current text contents of a QComboBox?

Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the option is selected, but the problem is that when the…
Ben
  • 5,525
  • 8
  • 42
  • 66
44
votes
2 answers

PyQt proper use of emit() and pyqtSignal()

I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from…
Max
  • 2,072
  • 5
  • 26
  • 42
43
votes
6 answers

QListWidget adjust size to content

Is it possible to adjust QListWidget height and width to it's content? sizeHint() always returns 256, 192 no matter what its content is. QListWidgetItem's sizeHint() returns -1, -1, so I can not get content width. Problem the same as here -…
Qiao
  • 16,565
  • 29
  • 90
  • 117
43
votes
1 answer

PyQt5 failing import of QtGui

I've just moved from PyQt4 to 5 and I'm having an issue with QtGui. I installed using the 32bit windows installer, not my own build. when I do: from PyQt5 import QtGui I get class MainWindow(QtGui.QMainWindow,…
Faller
  • 1,588
  • 3
  • 16
  • 27
42
votes
11 answers

PySide - PyQt : How to make set QTableWidget column width as proportion of the available space?

I'm developing a computer application with PySide and I'm using the QTableWidget. Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in the first column, then 3-digit numbers in the two…
AdrienW
  • 3,092
  • 6
  • 29
  • 59