动态库
test.h
#include <QtGui>
#if defined TEST
#define TEST_COMMON_DLLSPEC Q_DECL_EXPORT
#else
#define TEST_COMMON_DLLSPEC Q_DECL_IMPORT
#endif
class TEST_COMMON_DLLSPEC Widget : public QWidget
{
Q_OBJECT
public:
Widget();
};
test.cpp
#include "test.h"
#include <QtGui>
Widget::Widget() : QWidget() {}
test.pro
TEMPLATE = lib
# Input
SOURCES += test.cpp
HEADERS += test.h
DEFINES += TEST
静态库
test.h
#include <QtGui>
#include <QWidget>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget();
};
test.cpp
#include "qt_sharedlib.h"
#include <QtGui>
Widget::Widget() : QWidget() {}
tes