PDA

View Full Version : Objective C, Python and Ruby code with C++ Qt application



Berberis
5th June 2008, 10:00
Hello,

I need to embed ObjectiveC/Python/Ruby code in C++ Qt application. Did anybody do it before ? I'm not sure what I need to start:
a) Using some C++ language keywords as "extern C" and embed the source code ? But how to call those objects ?
b) Some specific wrapper that is C++ class that contains calls to ObjectiveC/Python/Ruby code ?
c) To compile ObjectiveC/Python/Ruby into library and then use some C++ compiler directives and embed it ? How to use header files then ?

Won't it cause any Qt compatibility problems ?

P.S. My end goal is to make use Applie Script program in Qt application. As Apple Script has bridge to ObjectiveC/Python/Ruby (http://www.apple.com/applescript/features/scriptingbridge.html), I want first call my program written in Apple Script from ObjectiveC/Python/Ruby and then call ObjectiveC/Python/Ruby code from C++ Qt application.

If somebody knows how to do that, please share your experience.
Thank you

patrik08
5th June 2008, 12:32
Apple script is like javascript to call

QProcess from qt help you


This sample make a background image on Desktop....



//MacOSX
#elif defined(Q_OS_MACX)

//create script
QString scriptFilename = ((Window*)qApp->mainWidget())->getTitle()->getAlbum()->getTmpDir() +
"/tmpBackgroundScript";

QFile file( scriptFilename );
if(file.open(IO_WriteOnly))
{
//-----
QTextStream stream;
stream.setDevice( &file );
stream.setEncoding( QTextStream::UnicodeUTF8 );
//-----
stream << "tell application \"Finder\"\n";
stream << "set pFile to POSIX file \"" << chosenFilename.ascii() << "\"\n";
stream << "set desktop picture to file pFile\n";
stream << "end tell";
}
file.close();

//run script to set background
QProcess p;
p.addArgument( "/usr/bin/osascript" );
p.addArgument( scriptFilename );
p.start();

//if there is an old file remove it
if(!oldFilename.isNull())
{ tmpDir.remove( oldFilename ); }

//-------------------------------
//UNIX
#else



Python on qt is possibel show the source code from
http://www.scribus.net/ and grep python command
other way is QScriptEngine http://doc.trolltech.com/4.3/qscriptengine.html

IMO: Java class QT button not work on firefox 3.

jacek
5th June 2008, 12:40
Check out PythonQt (http://pythonqt.sourceforge.net/).