##// END OF EJS Templates
- removed warnings...
- removed warnings - fixed some memory leaks (only on cleanup) - fixed bad QString usage as %s argument - added PythonQtQFileImporter, which implements a default importer using QFile - added PythonQt::self()->installDefaultImporter() to enable the new default importer - modified example to make use of new importer - removed ugly goto, which was copied from original zip import git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@43 ea8d5007-eb21-0410-b261-ccb3ea6e24a9

File last commit:

r8:f65f3e118cc5
r8:f65f3e118cc5
Show More
CPPPyWrapperExample.cpp
46 lines | 2.0 KiB | text/x-c | CppLexer
ezust
- Added CHANGELOG...
r2 #include <PythonQt.h>
#include <QtGui>
ezust
Added an example QFileImportInterface which doesn't work yet!...
r7
ezust
- Added CHANGELOG...
r2 int main (int argc, char* argv[]) {
QApplication app(argc, argv);
PythonQt::init();
PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
ezust
Added an example QFileImportInterface which doesn't work yet!...
r7 mainModule.evalScript(QString("import sys\n"));
ezust
- Added CHANGELOG...
r2 Q_ASSERT(!mainModule.isNull());
{
// evaluate a python file embedded in executable as resource:
mainModule.evalFile(":eyed3tagger.py");
ezust
Documentation updates only. No changes to code....
r6 // create an object, hold onto its reference
ezust
- Added CHANGELOG...
r2 PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
ezust
Documentation updates only. No changes to code....
r6 // tag goes out of scope, reference count decremented.
ezust
- Added CHANGELOG...
r2 }
ezust
Added an example QFileImportInterface which doesn't work yet!...
r7 {
// Allow the python system path to recognize QFile paths in the sys.path
florianlink
- removed warnings...
r8 //QFileImportInterface qfii;
PythonQt::self()->setImporter(NULL);
ezust
Added an example QFileImportInterface which doesn't work yet!...
r7 // append the Qt resource root directory to the sys.path
mainModule.evalScript("sys.path.append(':')\n");
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
ezust
- Added CHANGELOG...
r2 { // alternative using import and loading it as a real module from sys.path
// import sys first
mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath()));
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
qDebug() << "finished";
return 0;
}