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
30
votes
5 answers

PyQt: RuntimeError: wrapped C/C++ object has been deleted

If I run this code: #!/usr/local/bin/ python3 import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QMainWindow): def __init__(self): super().__init__() self.button1 = QPushButton("1") …
Brian
  • 3,453
  • 2
  • 27
  • 39
30
votes
2 answers

How to set QWidget background color?

The line w.setBackgroundRole(QPalette.Base) in the code below has no effect. Why? How do I fix that? import sys from PySide.QtCore import * from PySide.QtGui import * app = QApplication(sys.argv) w =…
Johan Råde
  • 20,480
  • 21
  • 73
  • 110
29
votes
8 answers

PyQt: Show menu in a system tray application

First of all, I'm an experienced C programmer but new to python. I want to create a simple application in python using pyqt. Let's imagine this application it is as simple as when it is run it has to put an icon in the system tray and it has offer…
Nextorlg
  • 794
  • 1
  • 8
  • 16
29
votes
3 answers

How can I check if a keyboard modifier is pressed (Shift, Ctrl, or Alt)?

I am building a UI with Qt Creator and I want buttons to perform different actions with different modifiers. So I thought I could call functions with dynamic string properties that would perform the action depending on the modifier. Is there a…
user1087058
  • 349
  • 1
  • 3
  • 5
29
votes
7 answers

How can I change the cursor shape with PyQt?

I have a simple application that runs a process that can last for several minutes before completing. I am trying to provide an indication to the user that it is processing the request - such as changing the cursor to an hourglass. But I cannot…
TimothyAWiseman
  • 14,385
  • 12
  • 40
  • 47
29
votes
7 answers

Getting realtime output from ffmpeg to be used in progress bar (PyQt4, stdout)

I've looked at a number of questions but still can't quite figure this out. I'm using PyQt, and am hoping to run ffmpeg -i file.mp4 file.avi and get the output as it streams so I can create a progress bar. I've looked at these questions: Can ffmpeg…
Jason O'Neil
  • 5,908
  • 2
  • 27
  • 26
29
votes
2 answers

Python: PyQt Popup Window

So I've been creating my GUI with Qt for my Python application. I've now come to a situation where after a button has been pushed the appropriate deferred gets executed, we perform some tasks then I need to open up a separate window that contains…
Morphine
  • 643
  • 2
  • 6
  • 11
29
votes
2 answers

Why do I need to decorate connected slots with pyqtSlot?

I'm using pyqt5, and I have several methods connected using code similar to the following: self.progress.canceled.connect(self.cancel) Where, for example, self.cancel is: def cancel(self): self.timer.stop() This code seems to work cleanly in…
NirIzr
  • 3,131
  • 2
  • 30
  • 49
29
votes
2 answers

Multiple inheritance metaclass conflict

I need a double inheritance for a class. I tried several syntaxes but I don't understand the concept of metaclass. from PyQt5.QtGui import QStandardItem from configparser import ConfigParser class FinalClass(ConfigParser, QStandardItem): def…
Mauricio
  • 670
  • 1
  • 8
  • 23
29
votes
2 answers

Why do I need "sys.argv" to start a QApplication in PyQt?

I try to understand what PyQt does. And one of the first things I didn't, was: QApplication(sys.argv) Why do I have to give QApplication this argument? I know what sys.argv does. But in my Scripts I wouldn't need it.
Sir2B
  • 1,029
  • 1
  • 10
  • 17
29
votes
1 answer

How exactly does addStretch work in QBoxLayout?

I'm doing a PyQt4 tutorial about box layouts. But I dont understand how addStretch works. If i use vbox.addStretch(1) and hbox.addStretch(1), the two buttons appear down-right. Why? if i comment vbox.addStretch(1) and hbox.addStretch(1) out, the…
Hubschr
  • 1,285
  • 6
  • 18
  • 35
28
votes
2 answers

Updating GUI elements in MultiThreaded PyQT

I was researching for some time to find information how to do multithreaded program using PyQT, updating GUI to show the results. I'm used to learning by example and i can't find (yes i was looking for weeks) any simple example of program using…
Nuncjo
  • 1,290
  • 3
  • 15
  • 16
28
votes
1 answer

Fullscreen with pyqt4?

I'm new to pyqt and I've been looking for some docs about pyqt and fullscreen mode. but I couldn't find nothing. So here is my question: is there any way to run a PyQT 4 application on fullscreen?
CoCoMonk
  • 512
  • 1
  • 5
  • 9
28
votes
1 answer

How do I configure the behavior of the Qt4Agg backend?

In an earlier question I learned that the behavior on show() was dependent on the backend in use by matplotlib. At that time I was looking for a way to keep show() from deleting the drawing elements of a figure, concluding that by switching from…
2NinerRomeo
  • 2,687
  • 4
  • 29
  • 35
28
votes
5 answers

Resize column width to fit into the QTableWidget pyqt

I've googled around but I'm not able to find a solution to my problem. I have a QTableWidget with 2 columns and what I'm trying to do is to make them visible to the whole widget without the horizontal scrollbar to appear. With a picture it should be…
matteo
  • 4,683
  • 9
  • 41
  • 77