Skip to content

Commit 52264f7

Browse files
author
ezust
committed
Documentation updates only. No changes to code.
git-svn-id: http://svn.code.sf.net/p/pythonqt/code/trunk@41 ea8d5007-eb21-0410-b261-ccb3ea6e24a9
1 parent 9cd096b commit 52264f7

File tree

7 files changed

+34
-18
lines changed

7 files changed

+34
-18
lines changed

CHANGELOG.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ florianlink | 2008-09-01
55
- merged in features/fixes from the MeVisLab repository:
66
- added createModuleFromFile/createModuleFromScript/createUniqueModule
77
- switched object destruction to use QPointer and lazy wrapper removal to avoid expensive objectDestroyed signal connections
8-
- added hash() support for PythnQtWrapper object
8+
- added hash() support for PythonQtWrapper object
99
- added support for signal to python function connections where the function has less arguments than the emitted signal
1010
- added setQObject[NoLonger]WrappedCallback API to support external reference counting on QObjects that are exposed to PythonQt
1111
- implemented flush on std redirect to support python logging framework

examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ int main (int argc, char* argv[]) {
88
{
99
// evaluate a python file embedded in executable as resource:
1010
mainModule.evalFile(":eyed3tagger.py");
11+
// create an object, hold onto its reference
1112
PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
1213
Q_ASSERT(!tag.isNull());
1314
tag.call("setFileName", QVariantList() << "t.mp3");
1415
QVariant fn = tag.call("fileName", QVariantList());
1516
Q_ASSERT(fn.toString() == QString("t.mp3"));
17+
// tag goes out of scope, reference count decremented.
1618
}
1719
qDebug() << "test1";
1820
{ // alternative using import and loading it as a real module from sys.path
1921
// import sys first
2022
mainModule.evalScript(QString("import sys\n"));
2123
// append the current directory to the sys.path
2224
mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath()));
23-
2425
mainModule.evalScript("import eyed3tagger\n");
2526
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
2627
Q_ASSERT(!tag.isNull());
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
It also shows how to add user defined Python classes to the
2-
embedded Python mainModule.
1+
This example shows how to add user defined Python classes
2+
to the embedded Python mainModule.
3+
34
It also shows how to create objects in Python,
45
hold onto reference counted smart pointers to them from
56
a Qt application, and invoke methods on them via
67
the PythonQtObjectPtr interface.
7-
8-
9-

examples/PyGettingStarted/GettingStarted.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ def appendLine():
2424

2525
# show the window
2626
box.show()
27+

examples/PyGettingStarted/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ int main( int argc, char **argv )
6060
// evaluate a simple python script and receive the result a qvariant:
6161
QVariant result = mainModule.evalScript("19*2+4", Py_eval_input);
6262

63+
// Create object from python, hold onto reference in C++:
64+
PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
65+
Q_ASSERT(!tag.isNull());
66+
67+
// call python methods from C++
68+
tag.call("setFileName", QVariantList() << "t.mp3");
69+
QVariant fn = tag.call("fileName", QVariantList());
70+
Q_ASSERT(fn.toString() == QString("t.mp3"));
71+
6372
// create a small Qt GUI
6473
QVBoxLayout* vbox = new QVBoxLayout;
6574
QGroupBox* box = new QGroupBox;
@@ -85,6 +94,8 @@ int main( int argc, char **argv )
8594
// shows how to call the method with a text that will be append to the browser
8695
mainModule.call("appendText", QVariantList() << "The ultimate answer is ");
8796

97+
98+
8899
return qapp.exec();
89100
}
90101

src/PythonQtDoc.h

+14-10
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@
5252
\section Introduction
5353
5454
\b PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com).
55-
It offers an easy way to embedd the Python scripting language into
55+
It offers an easy way to embed the Python scripting language into
5656
your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
5757
5858
In contrast to <a href="http://www.riverbankcomputing.co.uk/pyqt/">PyQt</a> , PythonQt is \b not a complete
5959
Python wrapper around the complete Qt functionality. So if you are looking for a way to
6060
write complete applications in Python using the Qt GUI, you should use PyQt.
6161
62-
If you are looking for a simple way to embed the Python language into your Qt Application
63-
and to script parts of your application via Python, PythonQt is the way to go!
62+
If you are looking for a simple way to embed Python objects into your C++/Qt Application
63+
and to script parts of your application via Python, PythonQt is the way to go!
6464
65-
PythonQt is a stable library that was developed to make the Image Processing and Visualization platform MeVisLab (http://www.mevislab.de)
65+
PythonQt is a stable library that was developed to make the
66+
Image Processing and Visualization platform MeVisLab (http://www.mevislab.de)
6667
scriptable from Python.
6768
6869
\section Licensing
@@ -76,12 +77,14 @@
7677
7778
\section Features
7879
80+
- Easy wrapping of Python objects from C++ with smart, reference-counting PythonQtObjectPtr.
81+
- Convenient conversions to/from QVariant for PythonQtObjectPtr.
7982
- Access all \b slots, \b properties, children and registered enums of any QObject derived class from Python
8083
- Connecting Qt Signals to Python functions (both from within Python and from C++)
81-
- Wrapping of C++ objects (which are not derived from QObject) via PythonQtCPPWrapperFactory
84+
- Wrapping of C++ objects (which are not derived from QObject) via PythonQtCppWrapperFactory
8285
- Extending C++ and QObject derived classes with additional slots, static methods and constructors (see Decorators)
8386
- StdOut/Err redirection to Qt signals instead of cout
84-
- Interface for creating your own \c import replacement, so that Python scripts can be e.g. signed/verified before they are executed (PythonQtImportInterface)
87+
- Interface for creating your own \c import replacement, so that Python scripts can be e.g. signed/verified before they are executed (PythonQtImportFileInterface)
8588
- Mapping of plain-old-datatypes and ALL QVariant types to and from Python
8689
- Support for wrapping of user QVariant types which are registerd via QMetaType
8790
- Support for Qt namespace (with all enumerators)
@@ -93,7 +96,7 @@
9396
Features that PythonQt does NOT support (and will not support):
9497
9598
- you can not derive from QObjects inside of Python, this would require wrapper generation like PyQt does
96-
- you can only script QObject derived classes, for normal C++ classes you need to create a PythonQtCPPWrapperFactory and adequate wrapper classes or add decorator slots
99+
- you can only script QObject derived classes, for normal C++ classes you need to create a PythonQtCppWrapperFactory and adequate wrapper classes or add decorator slots
97100
- you can not access normal member functions of QObjects, only slots and properties, because the \b moc does not store normal member functions in the MetaObject system
98101
99102
\section Interface
@@ -127,7 +130,7 @@
127130
<tr><td>OwnRegisteredMetaType</td><td>variant wrapper, optionally with a wrapper provided by addVariantWrapper()</td></tr>
128131
<tr><td>EnumType</td><td>integer (all enums that are known via the moc and the Qt namespace are supported)</td></tr>
129132
<tr><td>QObject (and derived classes)</td><td>QObject wrapper</td></tr>
130-
<tr><td>C++ object</td><td>CPP wrapper, either wrapped via PythonQtCPPWrapperFactory or just decorated with decorators</td></tr>
133+
<tr><td>C++ object</td><td>CPP wrapper, either wrapped via PythonQtCppWrapperFactory or just decorated with decorators</td></tr>
131134
<tr><td>PyObject</td><td>PyObject</td></tr>
132135
</table>
133136
@@ -182,8 +185,9 @@
182185
183186
\section CPP CPP Wrapping
184187
185-
You can create dedicated wrapper QObject for any C++ class. This is done by deriving from PythonQtCPPWrapperFactory
186-
and adding your factory via addWrapperFactory(). Whenever PythonQt encounters a CPP pointer (e.g. on a slot or signal)
188+
You can create dedicated wrapper QObject for any C++ class. This is done by deriving from PythonQtCppWrapperFactory
189+
and adding your factory via addWrapperFactory().
190+
Whenever PythonQt encounters a CPP pointer (e.g. on a slot or signal)
187191
and it does not known it as a QObject derived class, it will create a generic CPP wrapper. So even unknown C++ objects
188192
can be passed through Python. If the wrapper factory supports the CPP class, a QObject wrapper will be created for each
189193
instance that enters Python. An alternative to a complete wrapper via the wrapper factory are decorators, see \ref Decorators

src/PythonQtImportFileInterface.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
#include <QString>
4747
#include <QByteArray>
4848

49-
//! defines an abstract interface to file access for the Python import statement
49+
//! Defines an abstract interface to file access for the Python import statement.
50+
//! see PythonQt::setImporter()
5051
class PythonQtImportFileInterface {
5152

5253
public:

0 commit comments

Comments
 (0)