PDA

View Full Version : How to bind Qt3 and Qt4 main event loop.



Opilki_Inside
4th May 2006, 15:06
Hello All.

I have a dynamic library. It were written using Qt3. The library export some function with GUI. The functions doesn't contain any Qt3 special classes in interface... It's look like:


typedef char* (*pcl_show)(const char*, const char* , const char*, const char*, const char*);

The function shows some table on screen.

So, I can use this function in any programming language. I succesfully use it in Delphi and Qt3.

But when I start use Qt4 and try to include this library in my project I found that window (from my library) does not painting in my application.

What I must do to use my GUI Qt3 library in Qt4? I think this happend because of difference between QApplication of Qt4 and Qt3. Are they have a common qApp object?



P.S. Sorry for my "English". English is not my favourite language.

wysota
4th May 2006, 20:06
Did you recompile the library for Qt4?

Opilki_Inside
5th May 2006, 13:24
Did you recompile the library for Qt4?

No, I didn't. It is very difficult because this library depends on additional Qt3 designer plugins., so I need to recompile this plugins and so on... I just want to use this library in Qt4 with out recompile... Can I do that?

wysota
5th May 2006, 16:32
No, you have to recompile. Qt3 and Qt4 use separate event loops, you'd have to create separate QApplication objects and run them in different threads. I don't know if it's possible at all, as this could result in a namespace clash during linking.

Opilki_Inside
8th May 2006, 08:10
It's hard to understand, but I found a solution. If I create QApplication object in my library (Qt3) first, after that I create QApplication instance in my application (Qt4) then my program begin to work properly :)

wysota
8th May 2006, 09:17
And both of the loops run in the same thread?

Opilki_Inside
10th May 2006, 07:45
And both of the loops run in the same thread?

I did not create any thread manualy but two instance of QApplication. Probably QApplication create own thread and main event loop (?). I don't know exacatly... Can you explain?

wysota
10th May 2006, 08:04
Well... If you run QApplication::exec(), it never returns (or to be exact, returns when the application is about to close). To have two event loops running, you'd have to call QApplication::exec() for both application objects.