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
25
votes
5 answers

PyQt5: Center align a label

This should be really simple but I just can't find an answer for this. I've tried this PyQt4 code: label.setAlignment(Qt.AlignCenter) But that does not work.
Lachlan
  • 1,245
  • 5
  • 18
  • 34
25
votes
3 answers

QThread: Destroyed while thread is still running

I'm having problem with QThreads in python. I want to change background color of label. But My application crash while starting. "QThread: Destroyed while thread is still running" class MainWindow(QMainWindow): def __init__(self): …
Sergey Kostin
  • 359
  • 1
  • 3
  • 5
24
votes
3 answers

PyQt - how to add separate UI widget to QMainWindow

I've only recently started programming and Python (PyQt) in particular. I have my main QMainWindow class. But I wanted to separate it from UI widgets, so that all windows stuff (menus, toolbars, common buttons) are in QMainWindow, but all program/UI…
linuxoid
  • 1,415
  • 3
  • 14
  • 32
24
votes
5 answers

How to capture output of Python's interpreter and show in a Text widget?

I have a program in Python with PyQt, designed to run on Windows. This program makes a lot of operations and prints a lot of info. But as I want to freeze it and don't want the prompt screen to appear, I want that all that info appears in the main…
jonathan.hepp
  • 1,603
  • 3
  • 15
  • 21
24
votes
1 answer

Get all tabs widgets in QTabWidget

Is it possible to get all tabs widgets that where added by addTab(QWidget() in QTabWidget in a list. We can use self.findChildren(QWidget), but it also returns all other widgets inside itself, and there is no way to filter them.
Qiao
  • 16,565
  • 29
  • 90
  • 117
24
votes
3 answers

PyQt showing video stream from opencv

Try to link PyQt and Opencv video feed, can't understand how to apply while loop for continuously streaming video. It just take a still picture.Please can anyone help to solve the problem. PtQt=5 Python=3.6.1 class App(QWidget): def…
Taimur Islam
  • 960
  • 2
  • 11
  • 25
24
votes
6 answers

Python PyQt on macOS Sierra

How can I get to work PyQt 4 or 5 on a Mac with OS X Sierra? It seems that I have to wait for a new version of PyQt but I am not sure if that is actually true.
Bzzzt_90
  • 251
  • 1
  • 2
  • 3
24
votes
4 answers

Using lambda expression to connect slots in pyqt

I am trying to connect slots with lambda functions, but it's not working the way I expect. In the code below, I succeed in connecting the first two buttons correctly. For the second two, which I connect in a loop, this goes wrong. Someone before me…
zeus300
  • 1,017
  • 2
  • 12
  • 30
24
votes
2 answers

how to add a right click menu to each cell of QTableView in PyQt

I want to add a right click menu to delete, rename or open image in each of cell of QTAbleView in the rigt click menu, I have tried and found everyone is trying to add menu to a header in tableview, i tried below but that seems not working in the…
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
23
votes
5 answers

Removing dotted border without setting NoFocus in Windows PyQt

There are a few questions on SO about this, all of which seem to say that the only way to remove the dotted border is to set the focusPolicy on widget/item in question to NoFocus. While this works as a temporary fix, this prevents further…
Cryptite
  • 1,426
  • 2
  • 28
  • 50
23
votes
1 answer

PyQT open a web page with JS alert pop up will get SegFault. How to fix that?

I am learning PyQT programing, and when I try a simple test, I get Segmentation fault, here is my code pop.py: #! /usr/bin/python import sys from PyQt4.QtGui import QApplication from PyQt4.QtCore import QUrl from PyQt4.QtWebKit import QWebView app…
PasteBT
  • 2,128
  • 16
  • 17
23
votes
4 answers

QTreeView Checkboxes

I know this has been asked a bunch of times, but I cant seem to find anything relevant. Using the simpletreemodel tutorial that comes packaged with Qt, how would I add checkboxes?
Drise
  • 4,310
  • 5
  • 41
  • 66
23
votes
4 answers

Terminal in broken state (invisible text / no echo) after exit() during input() / raw_input()

I've been writing a small utility application using Python 3 (the below testcase also works in Python 2, however) and PyQt 4 that uses the code module to spawn a REPL prompt allowing interaction with a Qt window. Unfortunately I've hit a problem…
Sho
  • 231
  • 2
  • 4
23
votes
5 answers

Understanding the "underlying C/C++ object has been deleted" error

It's not the first time I am getting the RuntimeError: underlying C/C++ object has been deleted. I've solved it many times altering my code in a random but intuitive way but now I am facing this again and just don't understand why it happens... What…
Rizo
  • 3,003
  • 5
  • 34
  • 49
23
votes
3 answers

Importing resource file to PyQt code?

I have seen Qt documentary and a lot of questions less-similar to this one, But i still haven't figured out how can i do it. I'm not entirely sure how can i import resource file to Python code, so pixmap appears without any issues. I have all files…
ShellRox
  • 2,532
  • 6
  • 42
  • 90