| 132 | The {{{main.cpp}}} and {{{main.h}}} files are used to build a C++ Python wrapper. This wrapper is build against the the Android-compiled python libraries in {{{build_dependencies/python}}} by Necessitas. |
| 133 | |
| 134 | Once the APK is deployd to the device and started, this wrapper is run. It initializes it's build-in Python interpreter, which tries to start the {{{/data/data/org.modrana.PySide.Example/main.py}}} Python file. This Python code then imports PySide, instantiates a QApplication and starts the main loop. |
| 135 | |
| 136 | Behind the scenes, Necessitas handles wrapping the QApplication to an Android activity and showing it on the screen. It also handles other stuff like keyboard input & Qt Mobility. |
| 137 | |
| 138 | ====== main.h ====== |
| 139 | This file contains important paths for the C++ wrapper. |
| 140 | |
| 141 | {{{ |
| 142 | #ifndef MAIN_H |
| 143 | #define MAIN_H |
| 144 | |
| 145 | #define MAIN_PYTHON_FILE "/data/data/org.modrana.PySideExample/files/main.py" |
| 146 | |
| 147 | #define PYTHON_HOME "/data/data/org.modrana.PySideExample/files/python/" |
| 148 | |
| 149 | #define PYTHON_PATH "/data/data/org.modrana.PySideExample/files/python/lib/python2.7/lib-dynload:/data/data/org.modrana.PySideExample/files/python/lib/python2.7/:/data/data/org.modrana.PySideExample/files/python/lib/python2.7/site-packages:/data/data/org.modrana.PySideExample/files/python/lib" |
| 150 | |
| 151 | #define LD_LIBRARY_PATH "/data/data/org.modrana.PySideExample/files/python/lib:/data/data/org.modrana.PySideExample/files/python/lib/python2.7/lib-dynload:/data/data/org.kde.necessitas.ministro/files/qt/lib/" |
| 152 | |
| 153 | #define PATH "/data/data/org.modrana.PySideExample/files/python/bin:$PATH" |
| 154 | |
| 155 | #define THEME_PATH "/data/data/org.modrana.PySideExample/files/python/themes/" |
| 156 | |
| 157 | #define QML_IMPORT_PATH "/data/data/org.modrana.PySideExample/files/python/imports/" |
| 158 | |
| 159 | #endif // MAIN_H |
| 160 | }}} |
| 161 | |
| 162 | * {{{MAIN_PYTHON_FILE}}} - path to the main Python file to run once the application is started |
| 163 | * {{{PYTHON_HOME}}} |
| 164 | * {{{LD_LIBRARY_PATH }}} - '':'' separated list of paths used to look for libraries when loading them |
| 165 | * {{{PATH}}} - search path for executables |
| 166 | * {{{THEME_PATH}}} - path to the main themes folder for Qt Components |
| 167 | * {{{QML_IMPORT_PATH}}} - path to the Qt Components {{{imports}}} folder |
| 168 | |
| 169 | ====== main.cpp ====== |
| 170 | This is the C++ wrapper, it contains the embedded Python interpreter that is used to start the application and also sets some important environmental variables specified through {{{main.h}}} . |
| 171 | |
| 172 | ===== The example Python application ===== |