PySide Binding Generation Tutorial: Module 1 Creating the foo library: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
[[Category:LanguageBindings::PySide::Shiboken::PySide Binding Generation Tutorial]]<br />[toc align_right="yes&quot; depth="3&quot;] | |||
'''English''' "French&quot;:http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LIII | |||
=Creating the foo library= | * '''Note:''' this article is a member of the multipart "PySide Binding Generation Tutorial&quot;:http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Shiboken::PySide_Binding_Generation_Tutorial | ||
= Creating the foo library = | |||
This section presents the code and the build instructions for a very simple Qt-based library. The library will be used as the subject for this tutorial. | This section presents the code and the build instructions for a very simple Qt-based library. The library will be used as the subject for this tutorial. | ||
==The Source Code== | == The Source Code == | ||
There is only one class in this '''foo''' library plus a | There is only one class in this '''foo''' library plus a <code&gt;.pro&lt;/code&gt; file which means that the build system used will be '''qmake''' based. | ||
Save the files below in a directory called '''libfoo'''. Be aware that this directory will be referenced by the binding Makefile presented in a later section of this tutorial. If you want to use other names or paths, remember to change the binding Makefile accordingly. Blind copy’n’paste shortens your life. | Save the files below in a directory called '''libfoo'''. Be aware that this directory will be referenced by the binding Makefile presented in a later section of this tutorial. If you want to use other names or paths, remember to change the binding Makefile accordingly. Blind copy’n’paste shortens your life. | ||
===libfoo/foo.h=== | === libfoo/foo.h === | ||
<code><br />#ifndef FOO_H<br />#define FOO_H | |||
#include <QtCore/QtCore&gt; | |||
class Math : public QObject<br />{<br /> Q_OBJECT<br />public:<br /> Math() {}<br /> virtual ~Math() {}<br /> int squared(int x);<br />};<br />#endif // FOO_H<br /></code> | |||
===libfoo/foo.cpp=== | === libfoo/foo.cpp === | ||
<code><br />#include "foo.h&quot; | |||
int Math::squared(int x)<br />{<br /> return x * x;<br />}<br /></code> | |||
=== | === libfoo/foo.pro === | ||
<code><br />TEMPLATE = lib<br />TARGET = foo<br />DEPENDPATH ''= .<br />INCLUDEPATH''= .<br />HEADERS ''= foo.h<br />SOURCES''= foo.cpp<br /></code> | |||
To build the lib:<br /><code><br />$ cd libfoo<br />$ qmake<br />$ make<br /></code> |
Revision as of 09:42, 24 February 2015
[toc align_right="yes" depth="3"]
English "French":http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LIII
- Note: this article is a member of the multipart "PySide Binding Generation Tutorial":http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Shiboken::PySide_Binding_Generation_Tutorial
Creating the foo library
This section presents the code and the build instructions for a very simple Qt-based library. The library will be used as the subject for this tutorial.
The Source Code
There is only one class in this foo library plus a <code>.pro</code> file which means that the build system used will be qmake based.
Save the files below in a directory called libfoo. Be aware that this directory will be referenced by the binding Makefile presented in a later section of this tutorial. If you want to use other names or paths, remember to change the binding Makefile accordingly. Blind copy’n’paste shortens your life.
libfoo/foo.h
<br />#ifndef FOO_H<br />#define FOO_H
#include <QtCore/QtCore&gt;
class Math : public QObject<br />{<br /> Q_OBJECT<br />public:<br /> Math() {}<br /> virtual ~Math() {}<br /> int squared(int x);<br />};<br />#endif // FOO_H<br />
libfoo/foo.cpp
<br />#include "foo.h&quot;
int Math::squared(int x)<br />{<br /> return x * x;<br />}<br />
libfoo/foo.pro
<br />TEMPLATE = lib<br />TARGET = foo<br />DEPENDPATH ''= .<br />INCLUDEPATH''= .<br />HEADERS ''= foo.h<br />SOURCES''= foo.cpp<br />
To build the lib:
<br />$ cd libfoo<br />$ qmake<br />$ make<br />