@@ -64,7 +64,7 @@ class CustomObjectWrapper : public QObject {
6464
6565 Q_OBJECT
6666
67- public slots :
67+ public Q_SLOTS :
6868 // add a constructor
6969 CustomObject* new_CustomObject (const QString& first, const QString& last) { return new CustomObject (first, last); }
7070
@@ -82,68 +82,4 @@ public slots:
8282
8383};
8484
85-
86- // ------------------------------------------------------------------------------------------------
87- // alternative: we create a wrapper factory, which creates a wrapper object for each CPP instance:
88- // ------------------------------------------------------------------------------------------------
89-
90- // declare our own custom object
91- class CustomObject2 {
92- public:
93- CustomObject2 () {}
94- CustomObject2 (const QString& first, const QString& last) { _firstName = first; _lastName = last; }
95-
96- QString _firstName;
97- QString _lastName;
98-
99- };
100-
101-
102- // add a decorator that allows to access the CustomObject from PythonQt
103- class CustomObject2Wrapper : public QObject {
104-
105- Q_OBJECT
106-
107- public:
108- CustomObject2Wrapper (CustomObject2* obj) { _ptr = obj; }
109-
110- public slots:
111- // add access methods
112- QString firstName () { return _ptr->_firstName ; }
113-
114- QString lastName () { return _ptr->_lastName ; }
115-
116- void setFirstName (const QString& name) { _ptr->_firstName = name; }
117-
118- void setLastName (const QString& name) { _ptr->_lastName = name; }
119-
120- private:
121- CustomObject2* _ptr;
122- };
123-
124- // additional constructor/destructor for CustomObject2 (optional)
125- class CustomObject2Constructor : public QObject {
126-
127- Q_OBJECT
128-
129- public slots:
130- // add a constructor
131- CustomObject2* new_CustomObject2 (const QString& first, const QString& last) { return new CustomObject2 (first, last); }
132-
133- // add a destructor
134- void delete_CustomObject2 (CustomObject2* o) { delete o; }
135- };
136-
137- // a factory that can create wrappers for CustomObject2
138- class CustomFactory : public PythonQtCppWrapperFactory
139- {
140- public:
141- virtual QObject* create (const QByteArray& name, void *ptr) {
142- if (name == " CustomObject2" ) {
143- return new CustomObject2Wrapper ((CustomObject2*)ptr);
144- }
145- return NULL ;
146- }
147- };
148-
14985#endif
0 commit comments