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

How to retrieve the selected row(s) of a QTableView?

I'm using the QTableView class with this model: class PaletteTableModel(QtCore.QAbstractTableModel): def __init__(self,colors = [[]],headers =[],parent=None): QtCore.QAbstractTableModel.__init__(self, parent) …
Haussem ChƏdly
  • 249
  • 2
  • 4
  • 11
16
votes
3 answers

multiprocessing problem [pyqt, py2exe]

I am writing a GUI program using PyQt4. There is a button in my main window and by clicking this button. I hope to launch a background process which is an instance of a class derived from processing.Process. class…
Bing Jian
  • 994
  • 3
  • 10
  • 18
16
votes
1 answer

PyQt: How to make widget scrollable

I am trying to make my QGroupBox scrollable once it grows higher than 400px. The contents in the QGroupBox are generated using a for-loop. This is an example of how it was done: mygroupbox = QtGui.QGroupBox('this is my groupbox') myform =…
Chris Aung
  • 9,152
  • 33
  • 82
  • 127
16
votes
2 answers

Python - PyQT4 how to detect the mouse click position anywhere in the window?

I have 1024x768 resolution window, when there is a click or mouse over, i want to find the x, y values. How can i do that? import sys from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example,…
user285594
16
votes
3 answers

Placeholder for a custom widget

I am loading a QMainWIndow base from a *.ui file. Also, i have a custom widget i want to place somewhere on the form. Currently i put in the .ui file an empty QVBoxLayout named placeholder, and in the QMainWindow subclass do…
warvariuc
  • 57,116
  • 41
  • 173
  • 227
16
votes
6 answers

Focusing on a tabified QDockWidget in PyQt

I have three QDockWidgets which are tabbed at startup using QMainWindow.tabifyDockWidget. In the main window, after all of the addDockWidget calls: self.tabifyDockWidget(self.dock_widget1, self.dock_widget2) self.tabifyDockWidget(self.dock_widget1,…
brianz
  • 7,268
  • 4
  • 37
  • 44
16
votes
2 answers

PyQt4: combine textChanged and editingFinished for QLineEdit

Is there a way to combine textChanged and editingFinished for QLineEdit? The problem is that editingFinished is emitted even if I only move the cursor away from QLineEdit without any changes. Whereas I want to emit a signal only when any changes…
Ekaterina Mishina
  • 1,633
  • 5
  • 20
  • 23
16
votes
1 answer

Login dialog PyQt

I nearly finished my application, when the customer asked if I could implement some kind of login form on application startup. So far I have designed the UI, and tinkered about the actual execution. Username and password are irrelevant for…
ivica
  • 1,388
  • 1
  • 22
  • 38
15
votes
3 answers

How to get the original python data from QVariant

I am just learning python and Qt these days. So please consider that this will be a newbie question, but I am stuck here. import sys from PyQt4.QtCore import * data1 = 'string' data2 = QVariant(data1) data3 = data2.toPyObject() I expected data3 is…
Jonas Hong
  • 275
  • 1
  • 2
  • 7
15
votes
3 answers

dynamically adding and removing widgets in PyQt

using PyQt, I am trying to create an interface for which I can add or remove widget dynamically. I want to define a separate class for the widget that will be added or removed. I can't seem to be able to get the widget that I instantiate to display…
boundless
  • 151
  • 1
  • 1
  • 3
15
votes
2 answers

How do you set the column width on a QTreeView?

Bear with me, I'm still new to QT and am having trouble wrapping my brain around how it does things. I've created and populated a QTreeView with two columns: class AppForm(QMainWindow): def __init__(self, parent = None): super(AppForm,…
ashground
  • 239
  • 2
  • 3
  • 10
15
votes
2 answers

PyQt and context menu

I need to create a context menu on right clicking at my window. But I really don't know how to achieve that. Are there any widgets for that, or I have to create it from the beginning? Programming language: Python Graphical lib: Qt (PyQt)
Max Frai
  • 61,946
  • 78
  • 197
  • 306
15
votes
5 answers

Loop over widgets in PyQt Layout

My question is somewhat related to Get a layout's widgets in PyQT but it's not a duplicate. Instead of looking for a high level strategic view of how to do it, I'm trying to understand what the most idiomatic and straightforward way to do it would…
wrosecrans
  • 1,055
  • 1
  • 8
  • 14
15
votes
1 answer

How do you add folding to QsciLexerCustom subclass?

Consider this snippet: import sys import textwrap import re from PyQt5.Qt import * # noqa from PyQt5.Qsci import QsciScintilla from PyQt5.Qsci import QsciLexerCustom from lark import Lark, inline_args, Transformer class…
BPL
  • 9,632
  • 9
  • 59
  • 117
15
votes
2 answers

PyQt - Connect QAction to function

I am using a TrayIcon, I have added a "Exit" QAction, and now, I want to execute a certain function when clicking Exit in the TrayIcon menu. Here is the code I have : class TrayIcon(QSystemTrayIcon): """ Displays a system tray icon …
Rémy Kaloustian
  • 597
  • 6
  • 10
  • 22