From 479f5f799523bffbcc83dff581a2299c047c6fff Mon Sep 17 00:00:00 2001
From: tpearson
The library contains a single C++ class called Hello which is derived from -Qt's QLabel class. It behaves just like QLabel except that the text +Qt's TQLabel class. It behaves just like TQLabel except that the text in the label is hard coded to be Hello World. To make the example more interesting we'll also say that the library only supports Qt v3.0 and later, and also includes a function called setDefault() that is not implemented @@ -1006,16 +1006,16 @@ in the Windows version of the library.
// Define the interface to the hello library. -#include <qlabel.h> -#include <qwidget.h> -#include <qstring.h> +#include <tqlabel.h> +#include <tqwidget.h> +#include <tqstring.h> -class Hello : public QLabel { +class Hello : public TQLabel { // This is needed by the Qt Meta-Object Compiler. Q_OBJECT public: - Hello(QWidget *parent, const char *name = 0, WFlags f = 0); + Hello(TQWidget *parent, const char *name = 0, WFlags f = 0); private: // Prevent instances from being copied. @@ -1024,7 +1024,7 @@ private: }; #if !defined(Q_OS_WIN) -void setDefault(const QString &def); +void setDefault(const TQString &def); #endif
The corresponding SIP specification file would then look something like this:
@@ -1037,21 +1037,21 @@ void setDefault(const QString &def); %If (Qt_3_0_0 -) -class Hello : QLabel { +class Hello : TQLabel { %TypeHeaderCode #include <hello.h> %End public: - Hello(QWidget *parent /TransferThis/, const char *name = 0, WFlags f = 0); + Hello(TQWidget *parent /TransferThis/, const char *name = 0, WFlags f = 0); private: Hello(const Hello &); }; %If (!WS_WIN) -void setDefault(const QString &def); +void setDefault(const TQString &def); %End %End @@ -1079,7 +1079,7 @@ removed. This is not supported by SIP. of the constructor. It specifies that if the argument is not 0 (i.e. the Hello instance being constructed has a parent) then ownership of the instance is transferred from Python to C++. It is needed because Qt -maintains objects (i.e. instances derived from the QObject class) in +maintains objects (i.e. instances derived from the TQObject class) in a hierachy. When an object is destroyed all of its children are also automatically destroyed. It is important, therefore, that the Python garbage collector doesn't also try and destroy them. This is covered in @@ -1722,20 +1722,20 @@ Handwritten code must be provided to interpret the conversion correctly.This is a QObject * that is a C++ instance of a class derived from Qt's -QObject class.
+This is a TQObject * that is a C++ instance of a class derived from Qt's +TQObject class.
This is a QObject * that is a C++ instance of a class derived from Qt's -QObject class. It is used as the type of the receiver instead of const -QObject * in functions that implement a connection to a slot.
+This is a TQObject * that is a C++ instance of a class derived from Qt's +TQObject class. It is used as the type of the receiver instead of const +TQObject * in functions that implement a connection to a slot.
This is a QObject * that is a C++ instance of a class derived from Qt's -QObject class. It is used as the type of the receiver instead of const -QObject * in functions that implement a disconnection from a slot.
+This is a TQObject * that is a C++ instance of a class derived from Qt's +TQObject class. It is used as the type of the receiver instead of const +TQObject * in functions that implement a disconnection from a slot.
To take an example, QAccel::connectItem() connects an internally generated +
To take an example, TQAccel::connectItem() connects an internally generated signal to a slot. The signal is emitted when the keyboard accelerator is activated and it has a single integer argument that is the ID of the accelerator. The C++ signature is:
-bool connectItem(int id, const QObject *receiver, const char *member); +bool connectItem(int id, const TQObject *receiver, const char *member);
The corresponding SIP specification is:
@@ -1962,8 +1962,8 @@ made to each element of the list.The handwritten code must explicitly return a PyObject *. If there was an error then a Python exception must be raised and NULL returned.
-The following example converts a QList<QWidget *> instance to a Python -list of QWidget instances:
+The following example converts a QList<TQWidget *> instance to a Python +list of TQWidget instances:
%ConvertFromTypeCode PyObject *l; @@ -1973,13 +1973,13 @@ list of QWidget insta return NULL; // Go through each element in the C++ instance and convert it to a - // wrapped QWidget. + // wrapped TQWidget. for (int i = 0; i < sipCpp -> size(); ++i) { - QWidget *w = sipCpp -> at(i); + TQWidget *w = sipCpp -> at(i); PyObject *wobj; - // Get the Python wrapper for the QWidget instance, creating a new + // Get the Python wrapper for the TQWidget instance, creating a new // one if necessary, and handle any ownership transfer. if ((wobj = sipConvertFromInstance(w, sipClass_QWidget, sipTransferObj)) == NULL) { @@ -2041,21 +2041,21 @@ have to recognise the exact class, only the most specific sub-class that it can.The handwritten code must not explicitly return.
-The following example shows the sub-class conversion code for QEvent based +
The following example shows the sub-class conversion code for TQEvent based class hierarchy in PyQt:
class QEvent { %ConvertToSubClassCode - // QEvent sub-classes provide a unique type ID. + // TQEvent sub-classes provide a unique type ID. switch (sipCpp -> type()) { - case QEvent::Timer: + case TQEvent::Timer: sipClass = sipClass_QTimerEvent; break; - case QEvent::KeyPress: - case QEvent::KeyRelease: + case TQEvent::KeyPress: + case TQEvent::KeyRelease: sipClass = sipClass_QKeyEvent; break; @@ -2089,8 +2089,8 @@ specification. The code is also called to determine if the Python object is of the correct type prior to conversion.When used as part of a class specification it can automatically convert additional types of Python object. For example, PyQt uses it in the -specification of the QString class to allow Python string objects and -unicode objects to be used wherever QString instances are expected.
+specification of the TQString class to allow Python string objects and +unicode objects to be used wherever TQString instances are expected.The following variables are made available to the handwritten code:
The following example converts a Python list of TQPoint instances to a +QList<TQPoint> instance:
%ConvertToTypeCode // See if we are just being asked to check the type of the Python @@ -2142,8 +2142,8 @@ Classes. return 0; // Check the type of each element. We specify SIP_NOT_NONE to - // disallow None because it is a list of QPoint, not of a pointer - // to a QPoint, so None isn't appropriate. + // disallow None because it is a list of TQPoint, not of a pointer + // to a TQPoint, so None isn't appropriate. for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), sipClass_QPoint, SIP_NOT_NONE)) @@ -2154,17 +2154,17 @@ Classes. } // Create the instance on the heap. - QList<QPoint> *ql = new QList<QPoint>; + QList<TQPoint> *ql = new QList<TQPoint>; for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) { - QPoint *qp; + TQPoint *qp; int state; // Get the address of the element's C++ instance. Note that, in // this case, we don't apply any ownership changes to the list // elements, only to the list itself. - qp = reinterpret_cast<QPoint *>(sipConvertToInstance( + qp = reinterpret_cast<TQPoint *>(sipConvertToInstance( PyList_GET_ITEM(sipPy, i), sipClass_QPoint, 0, SIP_NOT_NONE, @@ -2184,7 +2184,7 @@ Classes. ql -> append(*qp); - // A copy of the QPoint was appended to the list so we no longer + // A copy of the TQPoint was appended to the list so we no longer // need it. It may be a temporary instance that should be // destroyed, or a wrapped instance that should not be destroyed. // sipReleaseInstance() will do the right thing. @@ -2387,7 +2387,7 @@ pointer to the structure or class.
The following simplified example is taken from PyQt. The QCustomEvent +
The following simplified example is taken from PyQt. The TQCustomEvent class allows arbitary data to be attached to the event. In PyQt this data is always a Python object and so should be handled by the garbage collector:
@@ -2431,7 +2431,7 @@ collector.
The following simplified example is taken from PyQt's QCustomEvent class:
+The following simplified example is taken from PyQt's TQCustomEvent class:
%GCTraverseCode PyObject *obj; @@ -2681,7 +2681,7 @@ template<Type *> { %TypeHeaderCode // Include the library interface to the type being mapped. -#include <qlist.h> +#include <tqlist.h> %End %ConvertToTypeCode @@ -2765,7 +2765,7 @@ template<Type *> %End }-
Using this we can use, for example, QList<QObject *> throughout the +
Using this we can use, for example, QList<TQObject *> throughout the module's specification files (and in any module that imports this one). The generated code will automatically map this to and from a Python list of QObject instances when appropriate.
@@ -3327,7 +3327,7 @@ cases the value is optional.The following example shows argument and function annotations:
-void exec(QWidget * /Transfer/) /ReleaseGIL, PyName=call_exec/; +void exec(TQWidget * /Transfer/) /ReleaseGIL, PyName=call_exec/;
Note that the current version of SIP does not complain about unknown annotations, or annotations used out of their correct context.
@@ -3948,13 +3948,13 @@ comes with a reference.