-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathFeatures.html
More file actions
123 lines (123 loc) · 9.89 KB
/
Copy pathFeatures.html
File metadata and controls
123 lines (123 loc) · 9.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>PythonQt: Features</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">PythonQt
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div><div class="header">
<div class="headertitle"><div class="title">Features</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="Builtin"></a>
Built-in Features</h1>
<p>The following are the built-in features of the <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> library:</p>
<ul>
<li>Access all <b>slots</b>, <b>properties</b>, children and registered enums of any QObject derived class from Python</li>
<li>Connecting Qt Signals to Python functions (both from within Python and from C++)</li>
<li>Easy wrapping of Python objects from C++ with smart, reference-counting <a class="el" href="classPythonQtObjectPtr.html" title="a smart pointer that stores a PyObject pointer and that handles reference counting automatically">PythonQtObjectPtr</a>.</li>
<li>Convenient conversions to/from QVariant for <a class="el" href="classPythonQtObjectPtr.html" title="a smart pointer that stores a PyObject pointer and that handles reference counting automatically">PythonQtObjectPtr</a>.</li>
<li>Wrapping of C++ objects (which are not derived from QObject) via <a class="el" href="classPythonQtCppWrapperFactory.html" title="Factory interface for C++ classes that can be wrapped by QObject objects.">PythonQtCppWrapperFactory</a></li>
<li>Extending C++ and QObject derived classes with additional slots, static methods and constructors (see Decorators)</li>
<li>StdOut/Err redirection to Qt signals instead of cout</li>
<li>Interface for creating your own <code>import</code> replacement, so that Python scripts can be e.g. signed/verified before they are executed (<a class="el" href="classPythonQtImportFileInterface.html">PythonQtImportFileInterface</a>)</li>
<li>Mapping of plain-old-datatypes and ALL QVariant types to and from Python</li>
<li>Support for wrapping of user QVariant types which are registerd via QMetaType</li>
<li>Support for Qt namespace (with all enumerators)</li>
<li>All <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> wrapped objects support the <a class="el" href="PythonQtConversion_8h.html#a1974947fc423c7148fb94a3b1188dbe6">dir()</a> statement, so that you can see easily which attributes a QObject, CPP object or QVariant has</li>
<li>No preprocessing/wrapping tool needs to be started, <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> can script any QObject without prior knowledge about it (except for the MetaObject information from the <b>moc</b>)</li>
<li>Multiple inheritance for C++ objects (e.g. if a QWidget is derived from QObject and QPaintDevice, <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> will automatically cast a QWidget to a QPaintDevice when needed)</li>
<li>Polymorphic downcasting (if e.g. <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> sees a QEvent, it can downcast it depending on the type(), so the Python code e.g. sees a QPaintEvent instead of a plain QEvent)</li>
<li>Deriving C++ objects from Python and overwriting virtual method with a Python implementation (requires usage of wrapper generator or manual work!)</li>
<li>Extensible handler for Python/C++ conversion of complex types, e.g. mapping of QVector<SomeObject> to/from a Python array</li>
<li>Setting of dynamic QObject properties via setProperty(), dynamic properties can be accessed for reading and writing like normal Python attributes (but creating a new property needs to be done with setProperty(), to distinguish from normal Python attributes)</li>
<li>Support for QtCore.Signal, QtCore.Slot and QtCore.Property, including the creation of a dynamic QMetaObject.</li>
</ul>
<h1><a class="anchor" id="FeaturesQtAll"></a>
Features with wrapper generator</h1>
<p><a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> offers the additional PythonQt_QtAll library which wraps the complete Qt API, including all C++ classes and all non-slots on QObject derived classes. This offers the following features:</p>
<ul>
<li>Complete Qt API wrapped and accessible</li>
<li>The following modules are available as submodules of the <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> module:<ul>
<li>QtCore</li>
<li>QtGui</li>
<li>QtNetwork</li>
<li>QtOpenGL (before Qt6)</li>
<li>QtSql</li>
<li>QtSvg</li>
<li>QtWebEngineWidgets</li>
<li>QtWebKit (when available)</li>
<li>QtXml</li>
<li>QtXmlPatterns (before Qt6)</li>
<li>QtMultimedia</li>
<li>QtQml</li>
<li>QtQuick</li>
</ul>
</li>
<li>Any Qt class that has virtual methods can be easily derived from Python and the virtual methods can be reimplemented in Python</li>
<li>Polymorphic downcasting on QEvent, QGraphicsItem, QStyleOption, ...</li>
<li>Multiple inheritance support (e.g., QGraphicsTextItem is a QObject and a QGraphicsItem, <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> will handle this well)</li>
<li>QtQuick support is experimental and currently it is not possible to register new qml components from Python</li>
</ul>
<h1><a class="anchor" id="Supported"></a>
Supported Versions</h1>
<p><a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> supports:</p><ul>
<li>Python 2 (>= Python 2.7)</li>
<li>Python 3 (>= Python 3.6)</li>
<li>Qt 4.x (Qt 4.7 and Qt 4.8 recommended) (not in the main branch, see below)</li>
<li>Qt 5.x (Tested with Qt 5.6, 5.11, 5.12 and 5.15)</li>
<li>Qt 6.x (Tested with Qt 6.5 - 6.7) - support may not be complete, support for optional modules may be added as needed</li>
</ul>
<p>The last working Qt4 version is available at svn branches/Qt4LastWorkingVersion or you can download the <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> 3.0 release. The current git main branch no longer supports Qt4, since we started to make use of some Qt5-only features.</p>
<h1><a class="anchor" id="Comparison"></a>
Comparison with PySide</h1>
<ul>
<li><a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> is not as pythonic as PySide in many details (e.g. buffer protocol, pickling, translation support, ...) and it is mainly thought for embedding and intercommunication between Qt/Cpp and Python</li>
<li><a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> offers properties as Python attributes, while PySide offers them as setter/getter methods (e.g. QWidget.width is a property in <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> and a method in PySide, though in PySide6 in can also be made a property)</li>
<li><a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> currently does not support instanceof checks for Qt classes, except for the exact match and derived Python classes</li>
<li>QObject.emit to emit Qt signals from Python is not yet implemented but <a class="el" href="classPythonQt.html" title="The main interface to the Python Qt binding, realized as a singleton.">PythonQt</a> allows to just emit a signal by calling it like a normal slot</li>
<li>Ownership handling of objects is not as complete as in PySide and PySide, especially in situations where the ownership is not clearly passed to C++ on the C++ API.</li>
<li>QStrings are always converted to unicode Python objects, QByteArray always stays a QByteArray and can be converted using QByteArray.data()</li>
<li>Qt methods that take an extra "bool* ok" parameter can be called passing PythonQt.BoolResult as parameter. In PySide, a tuple is returned instead. </li>
</ul>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Jun 5 2026 12:41:37 for PythonQt by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>