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 do I set item delegates for multiple columns in a model that is processed by a proxy model?

I set my item delegates like so: COMBOBOX_ITEMS_FRUITS = ['Apple', 'Banana'] COMBOBOX_ITEMS_COLORS = ['Red', 'Green', 'Blue'] self.treeview.setItemDelegateForColumn(COLUMN_A,…
FatHippo
  • 177
  • 3
  • 12
4
votes
1 answer

PyQt: Mouse events in QGraphicsView

I would like to write a simple program in Python with PyQt. I have a QGraphicsScene and I would like to do the following: There are 2 options using two RadioButtons: For generating points. This way if someone clicks on the scene an ellipse will…
Dàvid Nagy
  • 159
  • 3
  • 10
4
votes
1 answer

Pyqt: Enforcing sizeHint() dimensions on two-widget app with layout manager

I have two widgets residing one next to each other, WidgetA and WidgetB, on a QDialog, with a horizontal Layout Manager. I am trying to enforce the following size/resize policies: For WidgetA: Horizontally: Width should be 900 with the ability to…
so.very.tired
  • 2,958
  • 4
  • 41
  • 69
4
votes
2 answers

How can I print a QString containing a special character with python using PyQt?

I do not managed to simply print a QString variable containing a special character. I always get a UnicodeEncodeError: 'ascii' codec can't encode characters in position .... Here is the code I tried without success : var1 = "éé" #idem with…
oaimac
  • 784
  • 2
  • 12
  • 27
4
votes
1 answer

PyQt5: Check if mouse is held down in enter-event

My actual application is much more complicated than this, but the example below sums up the majority of my problem. I have multiple QLabels that I've subclassed to make them clickable. The labels display 16x16 images which requires a process of…
huntrvro
  • 43
  • 1
  • 1
  • 5
4
votes
1 answer

PyQt: pass the value from one class to another

If someone please can help me, I would like to get the value from this variable "self.item_clicked" from the Class First to the class Second Thanks in advance conn = sqlite3.connect('DBM.db') conn.text_factory = str c = conn.cursor() #for row in…
ShwSvn
  • 79
  • 2
  • 8
4
votes
1 answer

Increase the bottom margin in QTextEdit

I need to make the scrollbar enabled even if the number of lines is less than the height of the QTextEdit, like in below pic I tried setDocumentMargin() but it makes margin in all directions (left, right, top, and bottom) So, is there a way to…
4
votes
1 answer

floating QDockWidget does not close when parentWidget closes

I have two open MainWindows: MainWindowWithButton and MainWindowWithDock. The later contains a QDockWidget. IS behaviour: When the users makes the DockWidget floatable and closes MainWindowWithDock, the dockWidget doesn't close. SHOULD behaviour:…
TheTrowser
  • 363
  • 4
  • 14
4
votes
1 answer

Determining if key is pressed in expression (Python) (PyQT)

In the mouseMoveEvent method I've seen code like below to check if either the left or right mouse buttons are being pushed (as shown below). Is there a way to check if certain keyboard keys are currently being pressed? Ideally I would like to have…
4
votes
1 answer

QDateEdit.date().toString("MMMM dd, yyyy") does not display months in English

I have a QDateEdit which is called date. No matter what I do, I'm not able to make it display the months in English, it always displays them in my current locale. I've already tried: self.ui.date.setLocale(QtCore.QLocale( QtCore.QLocale.English,…
Eduardo
  • 631
  • 1
  • 12
  • 25
4
votes
1 answer

"QPainter::begin: Paint device returned engine == 0, type: 1"

I have the following test code: import sys from PySide.QtGui import * app = QApplication(sys.argv) widget = QWidget() painter = QPainter(widget) Upon creating the QPainter object, I get the error message: QPainter::begin: Paint device returned…
HelloGoodbye
  • 3,624
  • 8
  • 42
  • 57
4
votes
1 answer

pyqt5 textedit delete lines as they move past specified line

I'd like to setup the PYQT Qtextedit widget and use it to monitor another applications activity log(like tail -f on Linux). Long term I worry about it running for too long and using a lot of ram with the text that builds up. Is it possible to set a…
sidnical
  • 421
  • 1
  • 6
  • 23
4
votes
1 answer

PyQt5 multi thread

why the code doesn't work?? the video work file, when i tried to show a text in 2nd label it also show up.but If i want to change the value continuously like current time in the setText() what can i do? I am new in multi threading. import…
Taimur Islam
  • 960
  • 2
  • 11
  • 25
4
votes
2 answers

PyQt5 QThread Issue

I am trying to get the basics of QT5 threading. This is my first attempt, combined from various sources: import sys from time import sleep from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QGridLayout from PyQt5.QtCore import…
Anonimista
  • 185
  • 1
  • 11
4
votes
1 answer

Add cursor to matplotlib

This picture shows what I am trying to achieve: I am searching for a solution to add a cursor to my plotted line in matplotlib. The cursor should be draggable, but should only move on the plotted line. A label shall display the actual value of the…
MartinaW
  • 197
  • 1
  • 4
  • 7
1 2 3
99
100