PySide Binding Generation Tutorial: Module 1 Creating the foo library: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add "cleanup" tag)
(Convert ExpressionEngine links)
Line 4: Line 4:
[toc align_right="yes" depth="3"]
[toc align_right="yes" depth="3"]


'''English''' "French":http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LIII
'''English''' [http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LIII French]


* '''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
* '''Note:''' this article is a member of the multipart [http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Shiboken::PySide_Binding_Generation_Tutorial PySide Binding Generation Tutorial]


= Creating the foo library =
= Creating the foo library =

Revision as of 15:11, 4 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

[toc align_right="yes" depth="3"]

English French

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

.pro

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

#ifndef FOO_H
#define FOO_H

#include <QtCore/QtCore>

class Math : public QObject
{
 Q_OBJECT
public:
 Math() {}
 virtual ~Math() {}
 int squared(int x);
};
#endif // FOO_H

libfoo/foo.cpp

#include "foo.h"

int Math::squared(int x)
{
 return x * x;
}

libfoo/foo.pro

TEMPLATE = lib
TARGET = foo
DEPENDPATH ''= .
INCLUDEPATH''= .
HEADERS ''= foo.h
SOURCES''= foo.cpp

To build the lib:

$ cd libfoo
$ qmake
$ make