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

How to emit custom Events to the Event Loop in PyQt

I am trying to emit custom events in PyQt. One widget would emit and another would listen to events, but the two widgets would not need to be related. In JavaScript, I would achieve this by doing // Component 1 document.addEventListener('Hello', ()…
Andrei Cioara
  • 3,404
  • 5
  • 34
  • 62
4
votes
1 answer

pyuic5 - Unknown C++ class: QfontDatabase

Used Qt Designer 5.9.5 to built a simple ui with a QFontComboBox. When I run pyuic5 it generates an error; pyuic5 demoFontComboBox.ui -o demoFontComboBox.py Unknown C++ class: QfontDatabase The .ui file is;
dipi
  • 128
  • 5
4
votes
1 answer

What is the difference between an opencv BGR image and its reverse version RGB image[:,:,::-1]?

I'm trying to show an opencv image with a QLabel. I got two different versions of the image, first one is the opencv BGR image, the second one is the RGB image using image[:,:,::-1], the BGR version works fine but the RGB version doesn't work. The…
Yifeng_Li
  • 133
  • 2
  • 6
4
votes
2 answers

How to hide a PyQt application's icon from Mac OS X dock

How do I make a PyQt application (with which the user interacts solely via the system tray (in the Menu Bar)) hide itself from the Mac OS X dock?
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
4
votes
1 answer

QObject::setParent: Cannot set parent, new parent is in a different thread in Python

I am facing a problem with the GUI I developed using PyQt5. The app tries to update the value of a progress bar of the window from a different thread (QThreadPool()). When it tries to update the progress bar, the python gives a warning as…
user8026974
4
votes
1 answer

what is horizontalHeaderItem

I was following some examples to build QTableWidget with buttons inside cells and there was a suggestion to use QTableWidget.horizontalHeaderItem. Now, this works great but with it I am unable to get item back from specific row/column (as…
tmdag
  • 531
  • 6
  • 17
4
votes
1 answer

TextEdit programmatic way to setText without triggering textChanged Event?

I am using pyQt to display data in a textEdit then have the connected textChanged method to send the text to a server application. I need the same behavior exhibited from the QLineEdit.textEdited as textEdited in QLineEdit does not get triggered on…
Jesse_mw
  • 105
  • 2
  • 11
4
votes
1 answer

How to play multiple clips of a video one after another

I have a video, from which I am getting some clips by time interval, and I want to do the following: Make the clips play one after another - so first clip plays, then after it is done, then second plays, and so on... But currently, it's good, but…
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
4
votes
1 answer

How can I make a table that can collapse its rows into categories in Qt?

I want to make a table in Qt that can collapse and expand its rows into groups (the rows are grouped by the content of a specific column), such as this: All groups expanded: First group collapsed: When clicking on the "group header rows", all…
drakenation
  • 382
  • 3
  • 15
4
votes
1 answer

getting values of table view headers

I'm not able to access to the values of the headers of a table widget. I'm able to set them like: self.table_widget.setHorizontalHeaderLabels(words) I've tried all the methods of header view object without any positive result. Printing the header…
Manuel Zompetta
  • 394
  • 4
  • 17
4
votes
1 answer

PyQt5: How to connect() & emit()

I am trying to port code from PyQt4 to PyQt5 and am not understanding why the following does not work. The slot is not being called. I see a bunch of ticks and no tocks. What am I missing? from PyQt5 import QtCore import time # expect to see…
SoloPilot
  • 1,484
  • 20
  • 17
4
votes
1 answer

Two Shortcuts for One Button in PyQt

In PyQt, how would you tie in two shortcuts for one button? I have scoured the QT documentation and StackOverflow, but the only thing I found was Two shortcuts for one action, but that was for QT and I could not wrap my head around that.
4
votes
1 answer

PyQt5: Using google fonts

Is it possible to use google fonts in a PyQt5 application? I'm trying to add some text to a pixmap and want to be able to use google fonts if possible. https://fonts.google.com/. I haven't been able to find anything online regarding this. def…
4
votes
1 answer

How to get cursor click position in QGraphicsItem coordinate system?

I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image (QGraphicsItem) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please,…
Taras Mykhalchuk
  • 829
  • 1
  • 9
  • 20
4
votes
1 answer

How to make a QPushButton a loading button?

Is there a way to make a loading button out of a QPushButton? I want to do something like https://coreui.io/docs/components/loading-buttons/ but in Qt. Is this possible? I would like to make a loading/progress bar out of each list widget item like…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75