Hi everybody,

I am looking for a way to register non static methods of my MyWidget class as python methods.

MyWidget class is a QWidget class and it's on the main window. So I want to initialize
python when the app is launched then I want to retrive information from MyTableWidget (QTableWidget)
within MyWidget class. I like to register itemCount non-static method as python method. I could not do it
since non static object registration gives error on myPythonCommands below.

I checked boost:: python but could not find a way to do it. It's doc cover to create a python clas within
C++ but not his one as far as I know.

I was wondering if any of you know a way and point me to right direction?

Thank you very much



Qt Code:
  1. class MyTableWidget
  2. {
  3.  
  4. };
  5.  
  6. class MyWidget
  7. {
  8.  
  9. MyWidget()
  10. {
  11. Py_Initialize();
  12. Py_InitModule("myApp", myPythonCommands);
  13. }
  14. ~MyWidget()
  15. {
  16. Py_Finalize();
  17. }
  18.  
  19. int itemCount()
  20. {
  21. return table.itemCount(); //return item count (in table) to python
  22. }
  23.  
  24. MyTableWidget table;
  25. };
  26. static PyMethodDef myPythonCommands[] = {
  27. {"itemCount", itemCount, METH_NOARGS, ""}, // here is the register part
  28. {NULL, NULL, 0, NULL}
  29. };
To copy to clipboard, switch view to plain text mode