#ifndef _PYTHONQTDOC_H #define _PYTHONQTDOC_H /* * * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like. Any license provided herein, whether implied or * otherwise, applies only to this software file. Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: MeVis Research GmbH, Universitaetsallee 29, * 28359 Bremen, Germany or: * * http://www.mevis.de * */ //---------------------------------------------------------------------------------- /*! // \file PythonQtDoc.h // \author Florian Link // \author Last changed by $Author: florian $ // \date 2006-10 */ //---------------------------------------------------------------------------------- /*! \mainpage \section Introduction \b PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com). It offers an easy way to embedd the Python scripting language into your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x. In contrast to PyQt , PythonQt is \b not a complete Python wrapper around the complete Qt functionality. So if you are looking for a way to write complete applications in Python using the Qt GUI, you should use PyQt. If you are looking for a simple way to embed the Python language into your Qt Application and to script parts of your application via Python, PythonQt is the way to go! \section Licensing PythonQt is distributed under the LGPL license. \section Download PythonQt is hosted on SourceForge at http://sourceforge.net/projects/pythonqt , you can access it via SVN or download a tarball. \section Features - Access all \b slots and \b properties of any QObject derived class from Python - Connecting Qt Signals to Python functions - Wrapping of C++ objects (which are not derived from QObject) via PythonQtCPPWrapperFactory - StdOut/Err redirection to Qt signals instead of cout - Interface for creating your own \c import replacement, so that Python scripts can be e.g. signed/verified before they are executed (PythonQtImportInterface) - Mapping of plain-old-datatypes and many QVariant types to and from Python - No preprocessing/wrapping tool needs to be started, PythonQt can script any QObject without prior knowledge about it (except for the MetaObject information from the \b moc) \section Non-Features Features that PythonQt does NOT support (and will not support): - 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 - you can only script QObject derived classes, for normal C++ classes you need to create a PythonQtCPPWrapperFactory and adequate wrapper classes - you can not derive from QObjects inside of Python, this would require wrapper generation like PyQt does \section Interface The main interface to PythonQt is the PythonQt singleton. PythonQt needs to be initialized via PythonQt::init() once. Afterwards you communicate with the singleton via PythonQt::self(). \section Datatype Datatype Mapping The following table shows the mapping between Python and Qt objects:
Qt/C++ | Python |
---|---|
bool | bool |
double | float |
float | float |
char/uchar,int/uint,short,ushort,QChar | integer |
long | integer |
ulong,longlong,ulonglong | long |
QString | unicode string |
char* | str |
QStringList | tuple of unicode strings |
QSize | QSize wrapper |
QRect | QRect wrapper |
QPoint | QPoint wrapper |
QImage | QImage wrapper |
QPixmap | QPixmap wrapper |
QVariant | depends on type, see below |
QVariantList | tuple of objects |
QVariantMap | dict of objects |
QDate | string |
QTime | string |
QDateTime | string |
QObject (and derived classes) | QObject wrapper |