PDA

View Full Version : How to import Qt class into C++ project?



David812
19th July 2011, 16:25
Goodmorning everybody,

I'm trying to import qt written class into a C++ project.

Now the problem is that Qt exports classes by using the Key word

Q_DECL_EXPORT

and C++ imports classes by using __declspec (dllimport)

How is possible to match both languages??

Now the compiler arises a problem such as this :
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [src/RFM_plot_import.o] Error 1

Could you help me??
Thanks in advance!
Andrea

mcosta
19th July 2011, 16:47
What do you means for

"I'm trying to import qt written class into a C++ project."?
"How is possible to match both languages??"

Qt is written in C++.

Show your code, probably there are errors in source files.

d_stranz
20th July 2011, 04:31
On the Windows platform, Q_DECL_EXPORT is defined as __declspec(dllexport), which is completely compatible with __declspec (dllimport) for importing items defined in a DLL. Therefore there should be no problem using classes exported from a DLL using that declaration and importing them into your project.

Exactly what -are- you trying to do? Are the Qt classes actually defined in a DLL for which you have a header file? You probably don't need to use these keywords at all, if you have properly #defined QT_DLL either in your source file (or better) as a compiler option.

If you haven't done it correctly, you will most likely get linker errors, not compiler errors.

David812
12th September 2011, 11:19
So,
I'm doing an application which use the qwtplot to plot data and a QWTsamplingThread to sample data which will be plottet by the qwtplot.
Seeing that qwtplot must be inside a widget, i need to create an instance for a widget(which start the plot) and a sampling thread.

Since my application is a small part of a bigger C written software (At this point the Qt written plotting plotting application is working good), i need to link both,the customized qwtplot class (modified by me) and the customized QsamplingThread class (modified by me).
Now the problem is that (in my opinion) i need to include in the C++ application an instance for Qapplication and the relative method called Qapplication.exec() in order to start the application.
Anyone has ever done such a thing??
Anyone has any pattern to help me??

Thanks a lot
Andrea