Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Emitting a signal using c++ source created in eclipse to be used in a Slot in a Qt generated source header.
Lineaxe last edited by
Hmm, how would I create a signal in Eclipse c++ source code that I can use in my Qt created projects?
Eclipse c++ source code
What do you mean by that?
Do you have a .o file u link in or how is it "Eclipse c++ source code"
To emit signal, the emitting code must be part of Qt object model somehow.
Not sure how a foreign code could post signals.
Eclipse c++ source code
There's no such thing. Either source code is in C++ (which is a language) or it's not. The IDE/text editor used to write that source code has no bearing at all. You could write programs in
viif you wish.
Well put ,
The Eclipse IDE does produce C++ code ,much of the Code produced is transferable to QT compiler. However, Qt has its libraries and Eclipse has it's set (Of course you add in more libraries) .So I really meant code that was created to compile with Eclipse. Anyhow, the Eclipse code is compiled into a .so library which is being used in a Qt created program. I want to have the Eclipse produce some code that can be used to 'emit' a signal , which I can then use in a slot that has been created inside a Qt project source file header.
"The Eclipse IDE does produce C++ code" - do you mean a code generator?
Actually you as developer write C++ code, not Eclipse.
If you want to use Qt signals/slots then you have to use Qt. That means in your Eclipse project you have to use Qt.
Do you have to use Eclipse for that library? Why not work on it in QtCreator? It would make things easier.
Well , I wrote that library some time ago , I could cross compile it to an arm 6 computer . It also handled mixing c and c++ source. I was familiar with Eclipse from writing Perl and java code using it. So I learned what was needed to make the library classes work. I probably could create a similar library using QT , it would require learning how it is done in QT. But for the time being I do have the working .so library written.
You don't have to rewrite the library. Just change it a bit to be able to emit Qt signals.
Or provide something else in the library: for example a call-back (you pass function pointer to the library and in the library you call this call-back if you have new notifications). In this case you don't need to bother with Qt in your library.
Anyhow, the Eclipse code is compiled into a .so library which is being used in a Qt created program. I want to have the Eclipse produce some code that can be used to 'emit' a signal , which I can then use in a slot that has been created inside a Qt project source file header.
If I understand you correctly, this can't happen without modifying your library code (possibly heavily), as the library has no notion of the application's infrastructure (and this is normal). To sum up the library has no way of knowing what is declared in the application, what classes are available or what interfaces they expose.
One thing you could possibly do to work around this is to push an object to the library, which in turn will call a function of that object, and finally this object will emit a Qt signal that you can subscribe to in the application - the observer pattern (which is a glorified callback function basically).
You know , rewriting the Code to work in Qt isn't such a bad approach in my case. The library is very small at this point. It was written run c code along with c++ . In eclipse I ran into a problem where I couldn't use C++11 along with C++98 in the same project. (The c code required c++98) So , I made a library up that I could use with all my other c++11 code . I have used the library in both eclipse and Qt. So it does makes it more universal of a library than if I rewrite it with signals and slots in Qt. Callback functions are always a good option as well :)