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
21
votes
4 answers

Any really modern, good-looking desktop apps that are developed with PyQt/PySide?

I have started using Python for web development recently, it's kinda cool; I have seen programs that are developed in QT/C++, which is good enough in terms of esthetics; I have just noticed the new PySide project (which brings LGPL Qt license to…
Edwin Yip
  • 4,089
  • 4
  • 40
  • 86
21
votes
1 answer

Make an action when the QLineEdit text is changed (programmatically)

I have written the following code snippet with an QLineEdit that can be edited by pushing the button "Add Text". import sys import os from PyQt4 import QtGui from PyQt4 import * class SmallGUI(QtGui.QMainWindow): def __init__(self): …
Matteo NNZ
  • 11,930
  • 12
  • 52
  • 89
21
votes
5 answers

How to use QThread correctly in pyqt with moveToThread()?

i read this article How To Really, Truly Use QThreads; The Full Explanation, it says instead of subclass qthread, and reimplement run(), one should use moveToThread to push a QObject onto QThread instance using moveToThread(QThread*) here is the…
Shuman
  • 3,914
  • 8
  • 42
  • 65
21
votes
3 answers

How to stop a QThread from the GUI

This is a follow up question to a previous one I posted earlier. The problem is how to stop (terminate|quit|exit) a QThread from the GUI when using the recommended method of NOT subclassing Qthread, but rather vreating a QObject and then moving it…
stefano
  • 769
  • 2
  • 10
  • 24
21
votes
4 answers

What is the advantage of using the native C++ Qt over PyQt

I want to develop in Qt, and I already know Python. I am learning C++, so what are the advantages of programming Qt in C++ over Python? C++ seems more complicated, and seems like there is not much gain.
Orcris
  • 3,135
  • 6
  • 24
  • 24
20
votes
5 answers

Good PyQt tutorial needed

I'm starting getting into PyQt. Therefore I would need some good tutorials. I searched a bit but didn't find any good. Most tutorials only post "full" applications but don't go into detail. Can you advise me some? Currently im programming in…
Razer
  • 7,843
  • 16
  • 55
  • 103
20
votes
1 answer

Qt - How to get the pixel length of a string in a QLabel?

I have a QLabel of a fixed width. I need to check (periodically) that the entire string fits inside the QLabel at its current width, so I can resize it appropriately. To do this, I need to obtain the 'pixel length' of the string. (The total amount…
Anti Earth
  • 4,671
  • 13
  • 52
  • 83
20
votes
3 answers

converting QdateTime to normal python dateTime?

I have a lot of existing code that just uses the normal dateTime class in python, however in upgrading my program I am using the QtGui.QdateTimeEdit() class, but that class returns a QdateTime object that seems to be incompatible with the normal…
Scott C
  • 325
  • 1
  • 2
  • 7
20
votes
6 answers

matplotlib show() doesn't work twice

I have a strange problem, with matplotlib. If I run this program, I'm able to open and close several time the same figure. import numpy from pylab import figure, show X = numpy.random.rand(100, 1000) xs = numpy.mean(X, axis=1) ys = numpy.std(X,…
Sangi
  • 221
  • 1
  • 3
  • 5
20
votes
1 answer

Get text from qtextedit and assign it to a variable

When I try to get the text from the qtextedit created with PyQt5 Designer I get an error or "Python stop working" and the script stop automatically. I've tried multiple solutions but nothing works. I have to assign the text from the qtextedit to a…
Abunis
  • 207
  • 1
  • 2
  • 9
20
votes
8 answers

What ide is good for developing PyQt apps?

What ide is good for developing PyQt apps?
yesraaj
  • 46,370
  • 69
  • 194
  • 251
20
votes
2 answers

Qt: Erase background (Windows Aero Glass)

Update see Using Blur Behind on Windows for an example of using Qt and DWM.alt text http://labs.trolltech.com/blogs/wp-content/uploads/2009/09/blurbehind2.png Original question: I want to create a Windows Aero Glass window with Qt, now it looks…
Andrew T
  • 5,549
  • 7
  • 43
  • 55
20
votes
4 answers

How do I display real-time graphs in a simple UI for a python program?

I have a complicated algorithm that updates 3 histograms that are stored in arrays. I want to debug my algorithm, so I was thinking of showing the arrays as histograms in a user interface. What is the easiest way to do this. (Rapid application…
Neil G
  • 32,138
  • 39
  • 156
  • 257
20
votes
4 answers

Hiding console window of Python GUI app with py2exe

I have a Python program uses Qt (PyQt4 in fact) and when I launch it from its main.py, I get a console window and the GUI window (on Windows, of course). Then I compile my program with py2exe and main.exe is successfully created. However, if I run…
ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
20
votes
3 answers

PyQt5: Keyboard shortcuts w/ QAction

How do I implement keyboard shortcuts (to run a function) in PyQt5? I see I'm supposed QAction in one way or another, but I can't put the two and two together, and all examples don't seem to work with PyQt5 but instead PyQt4.
Lachlan
  • 1,245
  • 5
  • 18
  • 34