views:

258

answers:

2

Maybe its a very dumb question but I hope you can give me some answers.

I have a commercial application which uses Qt3 for its GUI and an embedded Python interpreter (command line) for scripting. I want to write a custom plugin for this application which uses Qt4. The plugin is mainly a subclassed QMainWindow-class that is linked into a dll (so I am on Windows) together with a boost python wrapper. The python wrapper should be the interface between my plugin and my commercial application.

So my question: is this possible?? So is running Qt3 code independent from running Qt4 code in the same application.

First experiments resulted in application shutdown, I will try to investigate this further...

Thank you!

Edit: My application crashed because I didn´t created a QT4 qapplication instance. So when I create the instance everything works well without the additional Qt namespace (which is suggested in the answers, so no need to recompile)! ;)

+3  A: 

See this thread on a Trolltech forum. (Well actually that's about Qt3 plugins in a Qt4 app but I suspect the answer is much the same).

timday
ok cool, I recompiled Qt with the namespace "QT4" and I proved that this namespace is linked into the qt dlls via a dependency walker tool. But a namespace definition like "#define QT_NAMESPACE QT4" never appeared in one of the qt header files, so QT_NAMESPACE was undefined. Do you have an answer for this behaviour?I manually defined the namespace at the beginning of the "qglobal.h" and it seems to work so far...
yoursort
You're probably operating on the bleeding edge of qt development now. Sounds like it might be worth submitting a bug report to trolltech if they missed the namespace macro off a file. I'd be surprised if the facility was in common use by many people at all.
timday
yoursort
+2  A: 

This might be possible by namespacing Qt. From configure --help;

-qtnamespace <name>  Wraps all Qt library code in 'namespace <name> {...}'.

Theoretically this should prevent the symbol clashes which is likely making your current approach fail.

Henrik Hartz