Results 1 to 9 of 9

Thread: convert c++ class to python code

  1. #1
    Join Date
    May 2008
    Location
    Tripoli Libya
    Posts
    70
    Thanks
    10
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default convert c++ class to python code

    hi
    how to write this in python :
    class MyClass : public QWidget {
    Q_OBJECT

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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,625
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: convert c++ class to python code

    That incomplete fragment of C++ probably looks something like this incomplete fragment of Python for PyQt:
    Qt Code:
    1. from PyQt4 import QtCore,QtGui
    2.  
    3. class MyClass(QtGui.QWidget):
    4. def __init__(self, _zz):
    5. QtGui.QWidget.__init__(self, _zz.somefunc())
    6. self.zz = _zz
    To copy to clipboard, switch view to plain text mode 
    but I am not a real Python-head

  3. The following user says thank you to ChrisW67 for this useful post:

    alrawab (20th June 2012)

  4. #3
    Join Date
    May 2008
    Location
    Tripoli Libya
    Posts
    70
    Thanks
    10
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: convert c++ class to python code

    thanks a lot

  5. #4
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: convert c++ class to python code

    Quote Originally Posted by ChrisW67 View Post
    That incomplete fragment of C++ probably looks something like this incomplete fragment of Python for PyQt:
    Qt Code:
    1. from PyQt4 import QtCore,QtGui
    2.  
    3. class MyClass(QtGui.QWidget):
    4. def __init__(self, _zz):
    5. QtGui.QWidget.__init__(self, _zz.somefunc())
    6. self.zz = _zz
    To copy to clipboard, switch view to plain text mode 
    but I am not a real Python-head
    you added the method call parens onto somefunc which isnt present in the c++.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,625
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: convert c++ class to python code

    ... which is why I prefaced it with "looks something like"

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: convert c++ class to python code

    In theory "somefunc" might be a variable
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    May 2008
    Location
    Tripoli Libya
    Posts
    70
    Thanks
    10
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: convert c++ class to python code

    Quote Originally Posted by wysota View Post
    In theory "somefunc" might be a variable
    or may might be a a car ?

  9. #8
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: convert c++ class to python code

    insightful...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: convert c++ class to python code

    Quote Originally Posted by alrawab View Post
    or may might be a a car ?
    It might even be a pointer to a function returning a car
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 0
    Last Post: 21st October 2010, 13:18
  2. execute python in the Qt code
    By gorka_sm in forum Newbie
    Replies: 0
    Last Post: 28th April 2010, 15:04
  3. Embedding python code in Qt
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2010, 18:02
  4. Replies: 0
    Last Post: 9th November 2009, 16:03
  5. Objective C, Python and Ruby code with C++ Qt application
    By Berberis in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2008, 12:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.