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
4
votes
1 answer

pyQt Hover event with Svg image

I've been working on this for some time now and I can't figure out what I'm doing wrong. I hope someone here can help. I'm trying to get hover events to work when I mouse over an Svg item that's in a QGraphicsScene. Here's the code that I've been…
Jeff
  • 6,932
  • 7
  • 42
  • 72
4
votes
1 answer

Dropping an external file into a QTreeWidget

I guess the implementation isn't quite the same for a QTreeWidget, but I'd like to be able to drop an external file, particularly an image or movie file into my QTreeWidget. I'm not trying to drag it into a specific QTreeWidgetItem, but rather just…
Cryptite
  • 1,426
  • 2
  • 28
  • 50
4
votes
1 answer

Can I attach objects to QListWidgetItems in PyQt?

Is it possible to set/get a object for an item in a QListWidget the same way you set/get the text of the item?
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
4
votes
1 answer

QWidget not deleted with parent window

Using the below code, the __del__ method of my Preview widget never gets called. If I uncomment the "del window" line, it does. Why? #!/usr/bin/env python from PyQt4 import QtGui class Preview(QtGui.QWidget): def __init__(self, parent): …
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
4
votes
1 answer

How to Include PyQt with Jython 2.5.2?

I am planning to use PyQt with Jython because my app is based on Java. I have installed Jython successfully. But i am lacking in including PyQt with Jython. Any suggestions would be appreciative! P.S: I am totally new to Python. Thanks
user405398
4
votes
2 answers

Popup, non-modal, in-line Dialog in PyQT

It's difficult to describe what I want to do here, so here's what I want: -Click a button that "pops up" a dialog. -This dialog, however, should be non-modal. -I'd also like for it to be sort of 'locked' with the parent app so if I moved it, it too…
Cryptite
  • 1,426
  • 2
  • 28
  • 50
4
votes
2 answers

How would I combine multiple .py files into one .exe with Py2Exe

I used PyQt to make a GUI for my program, but it has multiple .py files, 2 are them are classes, and one launches the code. So I was wondering, how would I combine them into one whole program? Here is a download link to all the .py files I will be…
Casey
  • 444
  • 1
  • 7
  • 22
4
votes
1 answer

QSql connect and read from Database example? - Driver not loaded

I've recently started found the need to change from the __mysql module to PyQt's QSql but have nooo idea whatsoever where to start. All I want to do (for now) is read from a database and print the results. This is the furthest I've gotten but I keep…
Jay
  • 3,373
  • 6
  • 38
  • 55
4
votes
1 answer

PyQt window focus events not called

I have a PyQt4 program where I'm trying to get notified when a window gets focus, following the advice in the QUndoGroup docs: It is the programmer's responsibility to specify which stack is active by calling QUndoStack::setActive(), usually when…
J.C.
  • 208
  • 1
  • 2
  • 5
4
votes
1 answer

Suppress PyQt event temporarily?

I'm populating a branch of a QTreeWidget and then setting the expanded attribute on the parent of the branch to true. The itemExpanded signal fires in response, which is not what I want. Is there a temporary way to suppress or absorb signals during…
iwonder
  • 97
  • 2
  • 5
4
votes
3 answers

Python namespaces: How to make unique objects accessible in other modules?

I am writing a moderate-sized (a few KLOC) PyQt app. I started out writing it in nice modules for ease of comprehension but I am foundering on the rules of Python namespaces. At several points it is important to instantiate just one object of a…
user405
  • 579
  • 7
  • 13
4
votes
2 answers

Painting QTreeViewItem expand buttons and sibling/child lines

I am using a QTreeView and a QItemDelegate to reimplement most of the paint routine. However, the expand/collapse buttons and the sibling/child lines are drawn automatically by some other paint routine. What is drawing them, and how can I control…
user297250
4
votes
1 answer

PyQt Slider does not move to position of setValue

I have a QSlider that I want to set it's value programmatically overtime not just initially. The issue is that when I set the value of the slider after I move it, the slider position does not move to the correct value position, but the value does…
Fayad
  • 110
  • 11
4
votes
3 answers

Hyperlinks in QTreeView without QLabel

I'm trying to display clickable hyperlinks in my QTreeView. I was able to do this using QLabels and QTreeView.setIndexWidget per the recommendations from this question. Hyperlinks in QTreeView Unfortunately, my QTreeView can be rather large (1000s…
user297250
4
votes
4 answers

PyQt4: Interrupt QThread exec when GUI is closed

I have a PyQt4 GUI that has three threads. One thread is a data source, it provides numpy arrays of data. The next thread is a calculation thread, it takes the numpy array (or multiple numpy arrays) via a Python Queue.Queue and calculates what…
djhoese
  • 3,567
  • 1
  • 27
  • 45