PDA

View Full Version : Calling a widget as a library / dll function from C code how to ?



gusQt1
1st May 2011, 16:47
Hello, please bare with me as I'm new hear and new to Qt for sure.

I have a very complex imbedded Linux application built under GCC, it is all written in C.
I have managed to build / compile a very simple widget example that are included with my development system. (I'm on TI's OMAP-L138 DVSDK system and evaluation board tools etc)...

I would like to add this very simple widget (a slider) to send signal to a slot I will hook to in my C code to vary a parameter in the C code... I would like to have the widget / slider to be running on my LCD display on the evaluation board and when the user moves it to send a signal to my C application.

I'd like to have this be similar to a dll or a library so as not to have to “compile in” the widget in my C code... Can anyone tell me where to look for examples or tutorials on calling a Qt object from my C code and how to make this widget a dll / library, and how to link it to my C code...

If I have not explained what I'm attempting, please send me a response and I will try to clarify...

Again I'm new hear on the steep learning curve...
Thank you all.

GusQt1
aka...Brian

tbscope
1st May 2011, 17:49
I'd like to have this be similar to a dll or a library so as not to have to “compile in” the widget in my C code... Can anyone tell me where to look for examples or tutorials on calling a Qt object from my C code and how to make this widget a dll / library, and how to link it to my C code...

The short answer is, you can not do this.

But, it is possible in another way.
I would suggest to put your C code into a library and call it from a real Qt application.

For signals and slots to work you need to have a Qt event loop running. The easiest way to do that is create a simple Qt application. Then I would call your C code from within the slot connected to the slider.

Putting your existing C code into a library should be straight forward.
Google contains lots of tutorials and documentation on how to do that. Usually it requires you to handle the main function (if it is an application right now), adjust the make files, recompile, add the library to the Qt program, include the header and rebuild.

gusQt1
6th May 2011, 14:20
Thanks tbscope:
I see now where I have to have Qt running in event loop... I'll try now to make full Qt app and include the relevant, i.e. my c functions to it. Just got the Blanchette / Summerfield book, and going through some of the on line training, as well... Learning... Sorry for the pre-mature question...
Thanks.