- 新建项目-Qt Library-假如项目名称为dllTest
dlltest.h
#pragma once
#include "dlltest_global.h"
class DLLTEST_EXPORT dllTest
{
public:
dllTest(){
}
~dllTest(){
}
}
#ifdef __cplusplus
extern "C"
{
#endif
void DLLTEST_EXPORT PluginStart(void *lParentWidget);
void DLLTEST_EXPORT PluginClose(bool bFlag);
void DLLTEST_EXPORT PluginCall(void (*f)(char*));
#ifdef __cplusplus
}
#endif
//DLLTEST_EXPORT根据项目名称变化,其即__declspec(dllexport)的宏定义
dlltest.cpp
#include "dlltest.h"
#include "mywidget.h"//项目中自己添加的界面类
static MyWidget *g_mywidget;
void __declspec(dllexport) PluginStart(void *lParentWidget)
{
if(NULL == g_mywidget)
{
g_mywidget = new MyWidget();
}
if (NULL != lParentWidget)
{
g_mywidget->setParent(lPar