创建自定义QT库 [英] Creating Custom QT Library
问题描述
我使用VS2005创建了一个静态Qt库。
I created a static Qt library by using VS2005.
它创建了一个额外的文件test_global.h除了预期的(test.h和test.cpp) 。
It created an extra file "test_global.h" besides expected ones(test.h and test.cpp).
test_global.h
test_global.h
#ifndef TEST_GLOBAL_H
#define TEST_GLOBAL_H
#include <Qt/qglobal.h>
#ifdef TEST_LIB
# define TEST_EXPORT Q_DECL_EXPORT
#else
# define TEST_EXPORT Q_DECL_IMPORT
#endif
#endif // TEST_GLOBAL_H
为什么生成此文件,我如何使用它?
Why this file is generated, how I suppose to use it?
感谢。
推荐答案
:
class TEST_EXPORT TestClass {
// ...
};
然后在您的库专业版档案中添加:
Then in your library pro file you add:
DEFINES += TEST_LIB
你的类头将有Q_DECL_EXPORT宏,这是Qt的方式告诉链接器导出这个类/方法,当你在一些应用程序中使用你的dll,头将有Q_DECL_IMPORT宏。
So during the dll compilation your class header will have "Q_DECL_EXPORT" macro which is Qt way to tell the linker "export this class/method", and when you use your dll in some application, the header will have "Q_DECL_IMPORT" macro.
有关详细信息,请参阅 Qt文档 。
For more information, check the Qt documentation.
这篇关于创建自定义QT库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!