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
34
votes
3 answers

PyQt: Always on top

This is on PyQt4, Linux and Python 2.5 Can I make PyQt set my window "always on top" over other applications? For example, in GTK i use the property: Modal. Now, in PyQt I am using a QWidget, but, I can't find a way to do that. Any ideas??
mRt
  • 1,223
  • 6
  • 18
  • 32
33
votes
3 answers

Proper way to quit/exit a PyQt program

I have a script which has a login screen and if the cancel button is pressed, I want to exit the application altogether. I have tried 3 ways: sys.exit() QApplication.quit() QCoreApplication.instance().quit() Only number 1 works. The other two…
Dkellygb
  • 866
  • 2
  • 8
  • 24
33
votes
3 answers

PyQt Widget connect() and disconnect()

Depending on a conditions I would like to connect/re-connect a button to a different function. Let's say I have a button: myButton = QtGui.QPushButton() For this example let's say I check if there is an internet connection. if connected == True: …
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
33
votes
2 answers

What's the difference in Qt between setVisible, setShown and show/hide

Please excuse this potentially noobish question but when trying to hide a QWidget what is the difference between calling setVisible(False), setShown(False) and hide()?
Jay
  • 3,373
  • 6
  • 38
  • 55
32
votes
6 answers

QWidget resize signal?

I want to take an action when a widget was resized. Is there a way to catch that without installing an event filter on that widget (and, obviously, without subclassing it)? AFAIK, QWidget does not have a resized signal.
warvariuc
  • 57,116
  • 41
  • 173
  • 227
32
votes
3 answers

How to create a scrollable QVBoxLayout?

I'm trying to put a QVBoxLayout inside a QScrollArea in order for it to be scrollable vertically. However items don't seem to be added to it. I saw a suggestion that I ought to create an inner widget that the ScrollArea uses and to place the layout…
Ross
  • 46,186
  • 39
  • 120
  • 173
32
votes
2 answers

How to Convert Qcolor value to hex value?

I have implemented a QColor dialog box which opens on certain condition. To get the selected color after final selection I use the method selectedColor() which returns the value in QColor. When I print that value, it's like…
vettipayyan
  • 3,150
  • 3
  • 25
  • 34
32
votes
6 answers

QListWidget and Multiple Selection

I have a regular QListWidget with couple of signals and slots hookedup. Everything works as I expect. I can update, retrieve, clear etc. But the UI wont support multiple selections. How do I 'enable' multiple selections for QListWidget? My limited…
Jeffrey Jose
  • 1,992
  • 2
  • 16
  • 21
32
votes
7 answers

Are there default icons in PyQt/PySide?

I'm reading a tutorial on PySide and I was thinking , do I need to find my own icons for every thing or is there some way to use some built in icons . That way I wouldn't need to find an entire new set of icons if I want my little gui to run on…
user1155844
  • 581
  • 1
  • 5
  • 10
31
votes
3 answers

How can I select by rows instead of individual cells in QTableView in PyQt?

In the sample code below (heavily influenced from here), I want the entire row of the clicked cell to be selected instead of the individual cell. How can I change the code to incorporate that? import re import operator import os import sys import…
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
31
votes
6 answers

pip install PyQt IOError

I'm trying to install PyQt package with pip, but I get this error: ~$ pip install PyQt Downloading/unpacking PyQt Downloading PyQt-x11-gpl-4.8.3.tar.gz (9.8Mb): 9.8Mb downloaded Running setup.py egg_info for package PyQt Traceback (most…
J91321
  • 437
  • 1
  • 5
  • 9
31
votes
1 answer

Python: How to Resize Raster Image with PyQt

I need to find a way to re-size an input raster image (such as jpg) to a specified width/height resolution (given in pixels). It would be great if PyQt while resizing a new image would keep an original image's aspect ratio (so there is no stretching…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
30
votes
3 answers

How to add items to a QComboBox in PyQt/PySide

I need some help adding some items to a QComboBox. So I have two comboboxes, and one populates the other depending on the item selected. My question is that, using additem for new items, it works, but if I choose another option for the combobox, it…
IordanouGiannis
  • 4,149
  • 16
  • 65
  • 99
30
votes
3 answers

How to configure PyQt4 for Python 3 in Ubuntu?

This question was originally asked in askubuntu.com but got no attention so I think maybe this is a better place to ask. I installed PyQt4 with synaptic. I'm using Python3 so I need to configure the path for PyQt4 in eclipse, but it seems synaptic…
Derrick Zhang
  • 21,201
  • 18
  • 53
  • 73
30
votes
5 answers

Sending custom PyQt signals?

I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two Qthreads. Main/GUI thread. Twitter fetch thread - fetches data from Twitter every X minutes. So, every X minutes my Twitter thread downloads a new set of status…
Enfors
  • 960
  • 2
  • 14
  • 25