PDA

View Full Version : convert c++ class to python code



alrawab
20th June 2012, 03:35
hi
how to write this in python :
class MyClass : public QWidget {
Q_OBJECT

MyClass::MyClass(otherclass * _zz):QWidget(_zz.somefunc),zz(_zz)

ChrisW67
20th June 2012, 04:12
That incomplete fragment of C++ probably looks something like this incomplete fragment of Python for PyQt:


from PyQt4 import QtCore,QtGui

class MyClass(QtGui.QWidget):
def __init__(self, _zz):
QtGui.QWidget.__init__(self, _zz.somefunc())
self.zz = _zz

but I am not a real Python-head

alrawab
20th June 2012, 05:01
thanks a lot

amleto
20th June 2012, 09:28
That incomplete fragment of C++ probably looks something like this incomplete fragment of Python for PyQt:


from PyQt4 import QtCore,QtGui

class MyClass(QtGui.QWidget):
def __init__(self, _zz):
QtGui.QWidget.__init__(self, _zz.somefunc())
self.zz = _zz

but I am not a real Python-head

you added the method call parens onto somefunc which isnt present in the c++.

ChrisW67
20th June 2012, 10:35
... which is why I prefaced it with "looks something like" ;)

wysota
20th June 2012, 11:06
In theory "somefunc" might be a variable ;)

alrawab
25th June 2012, 05:54
In theory "somefunc" might be a variable ;)
or may might be a a car ?

amleto
25th June 2012, 09:23
insightful...

wysota
25th June 2012, 09:43
or may might be a a car ?

It might even be a pointer to a function returning a car :)