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
20
votes
2 answers

How can I show a PyQt modal dialog and get data out of its controls once its closed?

For a built-in dialog like QInputDialog, I've read that I can do this: text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter your name:') How can I emulate this behavior using a dialog that I design myself in Qt Designer? For instance,…
Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98
20
votes
3 answers

Calling a function upon button press

I am trying to call function funcion when I click btn_brow_3. How could I accomplish this? When running the following code, I receive this error message: TypeError: connect() slot argument should be a callable or a signal not "nonetype" import…
user2109621
  • 341
  • 1
  • 3
  • 6
20
votes
2 answers

PyQT button clicked name

I have dynamically created buttons(QtoolButton) in gridLayout in pyQT. How can I get the name of the button clicked in the layout? I can't know the name before hand. Is there is any trigger to accomplish the task? Thanks in advance.
Program Questions
  • 440
  • 2
  • 6
  • 20
19
votes
1 answer

PyQt give color to a specific element

This might be an easy question, but I'm trying to give a color to a specific QLabel in my application and it doesn't work. The code I tried is the following : nom_plan_label =…
Johanna
  • 1,343
  • 4
  • 25
  • 44
19
votes
9 answers

Pip Install stuck on "Preparing Wheel metadata..." when trying to install PyQT5

I'm trying to install PyQT5 on my Raspberry Pi and used the command sudo pip3 install pyqt5. But it has been stuck on that for over an hour nowand I'm starting to get frustrated, since it still moves, so it didn't crash or anything. Is there a…
user14490575
19
votes
1 answer

QWebView undersampled SVG rendering

I'd like to use QWebView for an SVG thumbnailing job because it supports filters (unlike QSvgRender which only supports SVG Tiny 1.2). It seems to work quite well except for font rendering but that can be tweaked using fontconfig package. The…
skrat
  • 5,518
  • 3
  • 32
  • 48
19
votes
3 answers

Why in pyqt5 should I use pyuic5 and not uic.loadUi("my.ui")?

I've been experimenting with QT5 for Python, using pyqt5. I've noticed that most tutorials recommend using pyuic5 to convert the XML UI to Python code. I've also seen a couple of tutorials where instead they use uic.loadUi("myui.ui") to dynamical…
Frank
  • 459
  • 1
  • 5
  • 13
19
votes
2 answers

PyQt: No error msg (traceback) on exit

My PyQt application no longer prints the error (stderr?) to the console. I use QtDesigner and import the UI like this: from PyQt5 import QtCore, QtGui, QtWidgets import sys from PyQt5.uic import loadUiType Ui_MainWindow, QMainWindow =…
Jannis
  • 401
  • 1
  • 4
  • 9
19
votes
2 answers

Why is super used so much in PySide/PyQt?

Short version (tl;dr) I am learning PySide, and most online tutorials use super to initialize UI elements. Is this important (i.e., more scalable), or is it a matter of taste? Clarification: as I make more clear in the detailed version, this is not…
eric
  • 7,142
  • 12
  • 72
  • 138
19
votes
2 answers

How to apply style sheet to a custom widget in PyQt

# -*- coding: utf-8 -*- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * class MainWindow(QWidget): def __init__(self): super(MainWindow, self).__init__() self.setFixedWidth(200) …
Anke_Pet
  • 354
  • 1
  • 3
  • 10
19
votes
2 answers

PyCharm 3.0 fails to find PyQt5

I've got Python 3.3.2 installed (both x86 and x64 versions) and PyQt5.1 installed on top of them. Recently I installed PyCharm 3.0 Community Edition and configured to work with these Python interpreters. The problem is that PyQt5 is not shown in the…
sukhmel
  • 1,402
  • 16
  • 29
19
votes
2 answers

PyQt4: Difference between QWidget and QMainWindow

When reading through a PyQt4 tutorial, sometimes the examples uses QtGui.QMainWindow, sometimes it uses QtGui.QWidget. Question: How do you tell when to use which? import sys from PyQt4 import QtGui class Example(QtGui.QMainWindow): def…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
19
votes
1 answer

What is the easiest way to achieve realtime plotting in pyqtgraph

I do not get how to achieve realtime plotting in pyqtgraph. The realisation of that is not implemented in the documentation yet. Could anyone please provide an easy example ?
dan_0
  • 599
  • 1
  • 5
  • 17
19
votes
1 answer

How do you load .ui files onto python classes with PySide?

I've used PyQt for quite a while, and the entire time I've used it, there has been a pretty consistent programming pattern. Use Qt Designer to create a .ui file. Create a python class of the same type as the widget you created in the .ui file. When…
Brendan Abel
  • 35,343
  • 14
  • 88
  • 118
18
votes
8 answers

Selecting GUI on windows (wxPy vs pyQt)

We are planning to develop an application for monitoring and configuring our service (which is running on remote server). After long time of discussion, we decided for python as platform for our app, because we love and know python. But we don't…
Golovko
  • 609
  • 4
  • 8
  • 8