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
18
votes
6 answers

How to make a widget in the center of the screen in PySide/PyQt?

This code works, but I wonder if there is any simpler way: def center(self): qr = self.frameGeometry() cp = gui.QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
Freewind
  • 193,756
  • 157
  • 432
  • 708
18
votes
1 answer

Integrate Qt with Windows 7 taskbar using python?

I'm looking for a way to using some of the Windows 7 task bar features - specifically progressbar and jump lists - in a python application that uses Qt for the UI. The questions I've seen on SO are all 1-2 years old and either say Qt isn't there yet…
18
votes
3 answers

Hiding row labels

I'm using Qt4 to create a table, using the QTableWidget class. Problem is: I want to hide the row labels (i.e. the numbers). I just care about columns. I want to get this: (source: ldc.usb.ve) How can I accomplish this?
Emiliano
  • 22,232
  • 11
  • 45
  • 59
18
votes
1 answer

How to implement indentation based code folding in QScintilla?

The end goal here is to implement indentation based code folding in QScintilla similarly to the way SublimeText3 does. First of all, here's a little example of how you'd manually provide folding using QScintilla mechanisms: import sys from…
BPL
  • 9,632
  • 9
  • 59
  • 117
18
votes
2 answers

mapToScene requires the view being shown for correct transformations?

Primary issue: the QGraphicsView.mapToScene method returns different answers depending on whether or not the GUI is shown. Why, and can I get around it? The context is I'm trying to write unit tests but I don't want to actually show the tools for…
Ajean
  • 5,528
  • 14
  • 46
  • 69
18
votes
1 answer

AttributeError: 'Ui_MainWindow' object has no attribute 'setCentralWidget'

I am still working on the GUI for my Database and now i have a different error: Traceback (most recent call last): File "G:\Python\Database Kast Thuis\PyQt Test\MainMenu_ui.py", line 84, in ex = Ui_MainWindow() File…
That One
  • 581
  • 2
  • 6
  • 17
18
votes
1 answer

qApp versus QApplication.instance()

With PyQt5, both of these return the application object: app = QtWidgets.QApplication.instance() app = QtWidgets.qApp for i in app.arguments()[1:]: ... But why does print(QtWidgets.QApplication.instance() is QtWidgets.qApp) print False?
Sir Visto
  • 683
  • 1
  • 4
  • 9
18
votes
2 answers

QMessageBox change text of standard button

I want to use QMessageBox.Question for the icon. But i want to change the text of standard buttons. I do not want the text of buttons to be the "Yes" and "No". I want them to be "Evet" and "Iptal". Here my codes. choice =…
Taylan
  • 736
  • 1
  • 5
  • 14
18
votes
2 answers

How to make push button immediately disabled?

Hello everyone! I've found something strange on QPushButton instance. Oh, first of all, I am using.. windows 7 python 3.4 PyQt5 My test code is... # coding: utf-8 import sys, time from PyQt5.QtWidgets import QWidget, QApplication,…
passion053
  • 473
  • 3
  • 8
  • 21
18
votes
1 answer

How to use Qt Model/View framework with the Graphics View framework

I am working on a mapping application and need to display the data objects using a table, a form and as graphical objects in the map. I'm using PyQt, but that's not really important as this is a Qt question not a Python question. If I only needed…
Simon Hibbs
  • 5,941
  • 5
  • 26
  • 32
18
votes
3 answers

Draggable line with draggable points

I need to have 2 draggable points in a figureCanvas. But I have a supplementary constraint: the 2 points must be linked by a line. When I drag a point, of course (it wouldn't be funny otherwise), the line must be dynamically drawn, and still linked…
JPFrancoia
  • 4,866
  • 10
  • 43
  • 73
18
votes
7 answers

How to place an icon onto a QLineEdit?

There is a Search field with the magnification-lens and a greyed out "search" keyword at the top right corner of stackoverflow.com web site: I wonder if it is possible to achieve a same appearance with QLineEdit. If so then how?
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
18
votes
5 answers

python QLineEdit Text Color

I am trying to create a demonstration app to show how to change font colors. I can do it in QLabel and QTextEdit I have found no way to change the foreground text color for a QLineEdit. The only thing I've tried that does not throw an error…
Mike Sr
  • 511
  • 1
  • 5
  • 15
18
votes
2 answers

Add QWidget to QListWidget

I am trying to make a QListWidget in which each item is a simple widget that contains text and a pushbutton. I use the following: itemN = QtGui.QListWidgetItem() #Create widget widget = QtGui.QWidget() widgetText = QtGui.QLabel("I love…
eric
  • 7,142
  • 12
  • 72
  • 138
18
votes
3 answers

PyQt: Connecting a signal to a slot to start a background operation

I have the following code that performs a background operation (scan_value) while updating a progress bar in the ui (progress). scan_value iterates over some value in obj, emitting a signal (value_changed) each time that the value is changed. For…
Hernan
  • 5,811
  • 10
  • 51
  • 86