QT CTK插件开发(六) 多对一插件

news/2024/5/20 15:47:59/文章来源:https://blog.csdn.net/qq_37529913/article/details/129787270

        CTK在软件的开发过程中可以很好的降低复杂性、使用 CTK Plugin Framework 提供统一的框架来进行开发增加了复用性 将同一功能打包可以提供多个应用程序使用避免重复性工作、可以进行版本控制提供了良好的版本更新迭代需求、并且支持动态热拔插 动态更新、开发更加简单快捷 方便有用的开发,方便公司的持续技术积累和代码、模块、功能的统一管理和持续更新完成,对于企业实际开发过程中有比较重要的意义。

        本专栏文章较为全面的讲述了CTK插件开发的全部步骤,包括不限于 CTKPlugin插件、服务-接口(一服务对一接口)、服务-接口(多服务对一接口)、服务-接口(多接口对一服务)、CTK插件批量加载、CTK插件热拔插、CTK事件监听、CTK事件发送-类通信、CTK事件发送-信号槽、CTK版本控制、CTK版本控制、CTK插件元数据、CTK 服务工厂、CTK 服务追踪、控制中心软件开发CTK 等文章;

        CTK Plugin Framework基于Qt Plugin System和Qt Service Framework实现,并且增加了以下特性来扩展:插件元数据(由MANIFEST.MF文件提供)、一个定义良好的插件生命周期和上下文、综合服务发现和注册;

        Plugin System:CTK Core依赖于QtCore模块,CTK Plugin Framework基于Qt Plugin System。Qt API允许在运行时加载和卸载插件,热插拔功能在CTK Plugin Framework中得到了加强,以支持透明化延迟加载和解决依赖关系。

        插件的元数据被编译进插件内部,可以通过API进行提取。此外,插件系统还使用SQLite缓存了元数据,以避免应用程序加载时间问题。另外,Plugin System支持通过中央注册中心使用服务。

        Service Registry:Qt Service Framework是Qt Mobility项目发布的一个Qt 解决方案,Qt服务框架允许“声明式服务”和按需加载服务实现。为了启用动态(非持久性)服务,Qt Mobility服务框架可以与Service Registry一起使用。       

        本文是 QT CTK开发 第六篇文章,演示了

    CTK 开发优点
    降低复杂性:使用CTK开发只需进行插件开发,插件隐藏了内部实现,开发变得更加简单,因为只需要实现功能接口即可。
    可复用:标准化的组件模型,一个插件多个软件使用。
    版本控制:所有插件都经过严格的版本控制,只有能够协作的插件才会被连接在一起。
    动态更新:OSGi组件模型是一个动态模型,插件可以在不关闭整个系统的情况下被安装、启动、停止、更新和卸载。
    自适应:OSGI动态服务模型允许插件找出系统中可用的功能,并调整它们所能提供的功能,使得代码更加灵活, 并且能够更好地适应变化。
    透明性:插件和服务是CTK插件环境中的一等公民。管理API提供了对插件的内部状态的访问,以及插件之间的连接方式。
    开发简单:CTK插件相关的API非常简单,核心API不到25个类。核心API足以编写插件、安装、启动、停止、更新和卸载,并且还包含了所有的监听类。
    懒加载:插件可以用饿汉式启动,但是也可以被配置为仅当其它插件使用它们时才启动。服务可以被注册,但只有在使用时才创建。懒加载场景可以节省大量的运行时成本。
    非独占性:CTK Plugin Framework不会接管整个应用程序,可以选择性地将所提供的功能暴露给应用程序的某些部分。
    非侵入:在一个CTK插件环境中,不同插件均有自己的环境。插件可以使用任何设施,框架对此并无限制。

    CTK Plugin Framework不仅仅是组件的标准,还指定了如何安装和管理组件的API。API可以被插件用来提供一个管理代理,管理代理可以非常简单,如命令shell、图形桌面应用程序、Amazon EC2的云计算接口、或IBM Tivoli管理系统。标准化的管理API 使得在现有和未来的系统中集成CTK Plugin Framework变得非常容易。
 

© www.dreambegins.vip 保留所有权利

作者:双子座断点 CSDN

未经许可,禁止任何形式的转载、复制或引用。如出现盗版、未授权转载、本人有权对为许可网站、个人作者进行侵权投诉权利。

创作不易 尊重劳动成果

QT CTK插件开发(六) 多对一插件目录

1 项目结构

 2 QCTKPluginSingleCTK

2.1  qctkpluginsinglectk

2.2 qctkpluginsingleimplctk

2.3 pri文件

2.4 pro

2.5 元数据

3 QCTKPluginSingleQT

3.1 qctkpluginsingleqt

3.2 qctkpluginsingleimplqt

3.3 pri

3.4 pro

3.5 元数据

4 QCTKPluginGatherAPP

5 下载链接

6 其它系列文章


1 项目结构

 2 QCTKPluginSingleCTK

2.1  qctkpluginsinglectk

#ifndef QCTKPLUGINSINGLECTK_H
#define QCTKPLUGINSINGLECTK_H#include <ctkPluginActivator.h>
#include "qctkpluginsingleimplctk.h"
#include <QtDebug>
class QCTKPluginSingleCTK: public QObject, public ctkPluginActivator
{Q_OBJECTQ_INTERFACES(ctkPluginActivator)Q_PLUGIN_METADATA(IID "QCTKPluginSingleCTK")
public:void start(ctkPluginContext* context);void stop(ctkPluginContext* context);
private:QCTKPluginSingleImplCTK *m_pImpl;
};#endif // QCTKPLUGINSINGLECTK_H#include "qctkpluginsinglectk.h"void QCTKPluginSingleCTK::start(ctkPluginContext* context)
{ctkDictionary properties;properties.insert(ctkPluginConstants::SERVICE_RANKING, 1);properties.insert("name", "Qt");m_pImpl = new QCTKPluginSingleImplCTK();context->registerService<QCTKPluginSingleImplCTK>(m_pImpl, properties);
}void QCTKPluginSingleCTK::stop(ctkPluginContext* context)
{Q_UNUSED(context)delete m_pImpl;
}

2.2 qctkpluginsingleimplctk

#ifndef QCTKPLUGINSINGLEIMPLCTK_H
#define QCTKPLUGINSINGLEIMPLCTK_H#include <QObject>
#include <QtDebug>
#include "QCTKPluginSingleService.h"class QCTKPluginSingleImplCTK: public QObject, public QCTKPluginSingleService
{Q_OBJECTQ_INTERFACES(QCTKPluginSingleService)
public:QCTKPluginSingleImplCTK();void welcome() Q_DECL_OVERRIDE;
};#endif // QCTKPLUGINSINGLEIMPLCTK_H#include "qctkpluginsingleimplctk.h"QCTKPluginSingleImplCTK::QCTKPluginSingleImplCTK()
{}void QCTKPluginSingleImplCTK::welcome()
{qDebug() << "QCTKPluginSingle CTK!";
}

2.3 pri文件

# CTK 相关库所在路径(例如:CTKCore.lib、CTKWidgets.lib)
CTK_LIB_PATH = E:\CTK\CTK-build\CTK-build\bin\ReleaseINCLUDEPATH += E:\CTK\CTK-master\Libs\CommandLineModules
INCLUDEPATH += E:\CTK\CTK-master\Libs\Core
INCLUDEPATH += E:\CTK\CTK-master\Libs\DICOM
INCLUDEPATH += E:\CTK\CTK-master\Libs\ImageProcessing
INCLUDEPATH += E:\CTK\CTK-master\Libs\PluginFramework
INCLUDEPATH += E:\CTK\CTK-master\Libs\QtTesting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Scripting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Testing
INCLUDEPATH += E:\CTK\CTK-master\Libs\Visualization
INCLUDEPATH += E:\CTK\CTK-master\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-master\Libs\XNATINCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Core
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\PluginFramework# 相关库文件(CTKCore.lib、CTKWidgets.lib)
LIBS += -L$$CTK_LIB_PATH -lCTKCore -lCTKWidgets# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCore
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgets
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgets
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgetsPlugins
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgetsPlugins
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsPluginsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCoreCppTests
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCoreCppTests
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreCppTestsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKDummyPlugin
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKDummyPlugin
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKDummyPluginINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFramework
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFramework
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFrameworkTestUtil
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFrameworkTestUtil
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkTestUtilINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release

2.4 pro

QT       += core gui widgetsTEMPLATE = lib
DEFINES += QCTKPLUGINSINGLECTK_LIBRARYCONFIG += c++11# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \qctkpluginsinglectk.cpp \qctkpluginsingleimplctk.cppHEADERS += \qctkpluginsinglectk.h \qctkpluginsingleimplctk.hDESTDIR = ../../pluginsfile.path = $$DESTDIR
file.files = MANIFEST.MF
INSTALLS += fileinclude(../CTKPath.pri )RESOURCES += \QCTKPluginSingleCTK.qrcINCLUDEPATH += E:\QT\QCTKView\QCTKPluginGather# Default rules for deployment.
unix {target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target

2.5 元数据

MANIFEST.MFPlugin-SymbolicName:QCTKPluginSingleCTK
Plugin-Version:1.0.0
Plugin-Number:100 #元数据

3 QCTKPluginSingleQT

3.1 qctkpluginsingleqt

#ifndef QCTKPLUGINSINGLEQT_H
#define QCTKPLUGINSINGLEQT_H#include <ctkPluginActivator.h>
#include "qctkpluginsingleimplqt.h"
#include <QtDebug>class  QCTKPluginSingleQT: public QObject, public ctkPluginActivator
{Q_OBJECTQ_INTERFACES(ctkPluginActivator)Q_PLUGIN_METADATA(IID "QCTKPluginSingleQT")
public:void start(ctkPluginContext* context);void stop(ctkPluginContext* context);
private:QCTKPluginSingleImplQT *m_pImpl;
};#endif // QCTKPLUGINSINGLEQT_H#include "qctkpluginsingleqt.h"void QCTKPluginSingleQT::start(ctkPluginContext* context)
{ctkDictionary properties;properties.insert(ctkPluginConstants::SERVICE_RANKING, 1);properties.insert("name", "Qt");m_pImpl = new QCTKPluginSingleImplQT();context->registerService<QCTKPluginSingleImplQT>(m_pImpl, properties);
}void QCTKPluginSingleQT::stop(ctkPluginContext* context)
{Q_UNUSED(context)delete m_pImpl;
}

3.2 qctkpluginsingleimplqt

#ifndef QCTKPLUGINSINGLEIMPLQT_H
#define QCTKPLUGINSINGLEIMPLQT_H#include <QObject>
#include <QtDebug>#include "QCTKPluginSingleService.h"class ctkPluginContext;
class QCTKPluginSingleImplQT: public QObject, public QCTKPluginSingleService
{Q_OBJECTQ_INTERFACES(QCTKPluginSingleService)
public:QCTKPluginSingleImplQT();void welcome() Q_DECL_OVERRIDE;
};#endif // QCTKPLUGINSINGLEIMPLQT_H#include "qctkpluginsingleimplqt.h"QCTKPluginSingleImplQT::QCTKPluginSingleImplQT()
{}void QCTKPluginSingleImplQT::welcome()
{qDebug() << "QCTKPluginSingle Qt!";
}

3.3 pri

# CTK 相关库所在路径(例如:CTKCore.lib、CTKWidgets.lib)
CTK_LIB_PATH = E:\CTK\CTK-build\CTK-build\bin\ReleaseINCLUDEPATH += E:\CTK\CTK-master\Libs\CommandLineModules
INCLUDEPATH += E:\CTK\CTK-master\Libs\Core
INCLUDEPATH += E:\CTK\CTK-master\Libs\DICOM
INCLUDEPATH += E:\CTK\CTK-master\Libs\ImageProcessing
INCLUDEPATH += E:\CTK\CTK-master\Libs\PluginFramework
INCLUDEPATH += E:\CTK\CTK-master\Libs\QtTesting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Scripting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Testing
INCLUDEPATH += E:\CTK\CTK-master\Libs\Visualization
INCLUDEPATH += E:\CTK\CTK-master\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-master\Libs\XNATINCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Core
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\PluginFramework# 相关库文件(CTKCore.lib、CTKWidgets.lib)
LIBS += -L$$CTK_LIB_PATH -lCTKCore -lCTKWidgets# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCore
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgets
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgets
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgetsPlugins
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgetsPlugins
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsPluginsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCoreCppTests
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCoreCppTests
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreCppTestsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKDummyPlugin
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKDummyPlugin
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKDummyPluginINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFramework
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFramework
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFrameworkTestUtil
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFrameworkTestUtil
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkTestUtilINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release

3.4 pro

QT       += core gui widgetsTEMPLATE = lib
DEFINES += QCTKPLUGINSINGLEQT_LIBRARYCONFIG += c++11# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \qctkpluginsingleimplqt.cpp \qctkpluginsingleqt.cppHEADERS += \qctkpluginsingleimplqt.h \qctkpluginsingleqt.hDESTDIR = ../../pluginsfile.path = $$DESTDIR
file.files = MANIFEST.MF
INSTALLS += fileinclude(../CTKPath.pri )RESOURCES += \QCTKPluginSingleQT.qrcINCLUDEPATH += E:\QT\QCTKView\QCTKPluginGather# Default rules for deployment.
unix {target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target

3.5 元数据

MANIFEST.MFPlugin-SymbolicName:QCTKPluginSingleQT
Plugin-Version:1.0.0
Plugin-Number:100 #元数据

4 QCTKPluginGatherAPP

核心代码

#include "mainwindow.h"#include <QApplication>#include <QDirIterator>
#include <QtDebug>#include "QCTKPluginSingleService.h"#include <ctkPluginFrameworkFactory.h>
#include <ctkPluginFramework.h>
#include <ctkPluginException.h>
#include <ctkPluginContext.h>#pragma execution_character_set("utf-8")int main(int argc, char *argv[])
{QApplication a(argc, argv);MainWindow w;ctkPluginFrameworkFactory frameWorkFactory;QSharedPointer<ctkPluginFramework> framework = frameWorkFactory.getFramework();try {// 初始化并启动插件框架framework->init();framework->start();qDebug() << "CTK Plugin Framework start ...";} catch (const ctkPluginException &e) {qDebug() << "Failed to initialize the plugin framework: " << e.what();return -1;}qDebug() << "********************";// 获取插件上下文ctkPluginContext* context = framework->getPluginContext();// 获取插件所在位置QString path = "E:\QT\QCTKView\QCTKPluginGather\plugins";// 遍历路径下的所有插件QDirIterator itPlugin(path, QStringList() << "*.dll" << "*.so", QDir::Files);while (itPlugin.hasNext()) {QString strPlugin = itPlugin.next();try {// 安装插件QSharedPointer<ctkPlugin> plugin = context->installPlugin(QUrl::fromLocalFile(strPlugin));// 启动插件plugin->start(ctkPlugin::START_TRANSIENT);qDebug() << "Plugin start:" << QFileInfo(strPlugin).fileName();} catch (const ctkPluginException &e) {qDebug() << "Failed to start plugin" << e.what();return -1;}}qDebug() << "********************";// 1. 获取所有服务QList<ctkServiceReference> refs = context->getServiceReferences<QCTKPluginSingleService>();foreach (ctkServiceReference ref, refs) {if (ref) {qDebug() << "Name:" << ref.getProperty("name").toString()<<  "Service ranking:" << ref.getProperty(ctkPluginConstants::SERVICE_RANKING).toLongLong()<< "Service id:" << ref.getProperty(ctkPluginConstants::SERVICE_ID).toLongLong();QCTKPluginSingleService* service = qobject_cast<QCTKPluginSingleService *>(context->getService(ref));if (service != Q_NULLPTR)service->welcome();}}qDebug() << "********************";// 2. 使用过滤表达式,获取感兴趣的服务refs = context->getServiceReferences<QCTKPluginSingleService>("(&(name=CTK))");foreach (ctkServiceReference ref, refs) {if (ref) {QCTKPluginSingleService* service = qobject_cast<QCTKPluginSingleService *>(context->getService(ref));if (service != Q_NULLPTR)service->welcome();}}qDebug() << "********************";// 3. 获取某一个服务(由 Service Ranking 和 Service ID 决定)ctkServiceReference ref = context->getServiceReference<QCTKPluginSingleService>();if (ref) {QCTKPluginSingleService* service = qobject_cast<QCTKPluginSingleService *>(context->getService(ref));if (service != Q_NULLPTR)service->welcome();}w.show();return a.exec();
}
PROQT       += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp \mainwindow.cppHEADERS += \mainwindow.hFORMS += \mainwindow.uiinclude(../CTKPath.pri )
INCLUDEPATH += E:\QT\QCTKView\QCTKPluginGather# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
# CTK 相关库所在路径(例如:CTKCore.lib、CTKWidgets.lib)
CTK_LIB_PATH = E:\CTK\CTK-build\CTK-build\bin\ReleaseINCLUDEPATH += E:\CTK\CTK-master\Libs\CommandLineModules
INCLUDEPATH += E:\CTK\CTK-master\Libs\Core
INCLUDEPATH += E:\CTK\CTK-master\Libs\DICOM
INCLUDEPATH += E:\CTK\CTK-master\Libs\ImageProcessing
INCLUDEPATH += E:\CTK\CTK-master\Libs\PluginFramework
INCLUDEPATH += E:\CTK\CTK-master\Libs\QtTesting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Scripting
INCLUDEPATH += E:\CTK\CTK-master\Libs\Testing
INCLUDEPATH += E:\CTK\CTK-master\Libs\Visualization
INCLUDEPATH += E:\CTK\CTK-master\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-master\Libs\XNATINCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Core
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\Widgets
INCLUDEPATH += E:\CTK\CTK-build\CTK-build\Libs\PluginFramework# 相关库文件(CTKCore.lib、CTKWidgets.lib)
LIBS += -L$$CTK_LIB_PATH -lCTKCore -lCTKWidgets# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCore
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgets
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgets
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKWidgetsPlugins
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKWidgetsPlugins
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKWidgetsPluginsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKCoreCppTests
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKCoreCppTests
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKCoreCppTestsINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKDummyPlugin
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKDummyPlugin
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKDummyPluginINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFramework
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFramework
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Releasewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/release/ -lCTKPluginFrameworkTestUtil
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/debug/ -lCTKPluginFrameworkTestUtil
else:unix: LIBS += -L$$PWD/../../../CTK/CTK-build/CTK-build/bin/ -lCTKPluginFrameworkTestUtilINCLUDEPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release
DEPENDPATH += $$PWD/../../../CTK/CTK-build/CTK-build/bin/Release

5 下载链接

https://mp.csdn.net/mp_download/manage/download/UpDetailed 密码: ctk123456

6 其它系列文章

QT CTK插件框架 (一 下载编译)_双子座断点的博客-CSDN博客

QT CTK控件 CTK开发(二)_双子座断点的博客-CSDN博客

QT 创建插件 CTK开发(三)_双子座断点的博客-CSDN博客

QT 插件通信接口调用 CTK开发(四)_双子座断点的博客-CSDN博客

说明:未完待续 作者近期会尽快整理涉及该系列文章 尽快完结该系列也会推出相关软件程序等...

对于之前的文章也会一直继续优化等...
 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_501432.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

chatgpt赋能python:Python如何进行算术运算

Python如何进行算术运算 Python是一种高级编程语言&#xff0c;适用于不同的应用场景&#xff0c;尤其是数据科学和机器学习。Python拥有强大的算术运算能力&#xff0c;使得它成为处理大规模计算任务的首选语言。 基本运算符 Python中的基本运算符包括加法(), 减法(-), 乘法…

chatgpt赋能python:Python如何优化SEO?

Python如何优化SEO&#xff1f; Python已经成为一种非常流行的编程语言。专业人士使用Python编写众多应用程序&#xff0c;将其应用于各种行业和领域。众所周知&#xff0c;搜索引擎是市场营销的重要组成部分。SEO是在网站和搜索引擎结果页面上提高网站排名的过程。在这个过程…

论文中文翻译——kAFL Hardware-Assisted Feedback Fuzzing for OS Kernels

本论文相关内容 论文下载地址——26th USENIX Security Symposium论文中文翻译——kAFL Hardware-Assisted Feedback Fuzzing for OS Kernels 文章目录 本论文相关内容前言kAFL&#xff1a;操作系统内核的硬件辅助反馈Fuzzing作者信息论文来源主办方信息摘要1 引言2 技术背景2…

【ArcGIS Pro二次开发】(34):从字符串中提取中文、英文、数字与特殊符号

这是一个基于字段计算的工具。 有时候我们会遇到一些混杂着各种中文、英文、数字、特殊符号的文字&#xff0c;这个工具的目的是从这些复杂文字中提取出想要的特定文字。 比如说从CAD测绘图中可以读取到类似【混3】、【砖2】的文字&#xff0c;如果想要从中提取出层数或结构&…

Agile | 聊聊敏捷开发

什么是敏捷开发 敏捷开发是一种迭代和增量的项目管理方法&#xff0c;优先考虑适应性、协作和快速交付&#xff0c;而不是遵循严格的计划[0]。它是在《敏捷软件开发宣言》和《12项原则》中表达的一组价值观和原则[1]。敏捷是基于这些价值观和原则的一组框架和实践的总称。敏捷…

C++11中条件标量和互斥锁应用出现死锁思考

条件变量和互斥锁在多线程同步过程中经常被使用&#xff0c;以下测试程序测试其使用。 目录 1.测试程序1 2.测试程序2 3.运行结果思考 1.测试程序1 #include <mutex> #include <deque> #include <iostream> #include <thread> #include <condi…

Day_43插入排序

目录 一. 关于插入排序 1. 排序的定义 2. 插入排序 二. 插入排序的实现过程 三. 代码实现过程 1. 插入排序核心代码 四. 代码展示 五. 数据测试 六. 总结 一. 关于插入排序 1. 排序的定义 排序&#xff0c;就是重新排列表中的元素&#xff0c;使表中的元素满足按关键字有序…

chatgpt赋能python:Python如何获取图片的尺寸

Python如何获取图片的尺寸 如果你在使用Python编程&#xff0c;常常需要获取图片的尺寸&#xff0c;本文将介绍如何使用Python获取图片的尺寸&#xff0c;同时还会介绍一些常用的Python库用于图像处理。 PIL库 PIL&#xff08;Python Imaging Library&#xff09;是Python中…

chatgpt赋能python:Python-如何快速高效地求两数之和

Python - 如何快速高效地求两数之和 介绍 Python 是一种高级编程语言&#xff0c;适用于各种领域的软件开发。本文将介绍使用 Python 完成两个数字之和的操作。Python 以其清晰、简洁、易于学习和使用的特性闻名于世&#xff0c;既能作为脚本语言&#xff0c;又能进行面向对象…

利用Zookeeper实现集群选举

什么是Zookeeper 分布式开源协调系统&#xff0c;数据模型简单&#xff0c;可以实现同步&#xff0c;配置管理&#xff0c;分组管理&#xff0c;分命名空间管理等。 技术本质 一个原子消息传递系统&#xff0c;它使所有服务器保持同步 FLP(3个科学家名字命名) 理论角度&…

Linux驱动开发(使用I2C总线设备驱动模型编写AT24C02驱动程序)

文章目录 前言一、I2C总线设备驱动模型二、设备树编写三、驱动程序编写1.提供i2c_driver结构体变量并且注册2.注册file_operations结构体3.操作AT24C02 四、应用程序编写五、上机测试总结 前言 本篇文章将讲解如何使用I2C总线设备驱动模型编写AT24C02驱动程序。 一、I2C总线设…

Python 类和对象

一、什么是类和对象 Python和Java一样&#xff0c;都是面向对象的编程语言&#xff0c;面向对象编程其实是一种封装代码的方法&#xff0c;把一些公共的属性或者方法封装到一个类中&#xff0c;然后再通过这个类可以创建多个对象&#xff0c;最后使用这些对象去调用这些封装起…

2023PS beta 官方注册安装教程

该教程为官方注册下载教程&#xff0c;无风险。 软件介绍 Adobe Photoshop 2023版(简称PS)是一款全球流行的专业图像处理软件及照片和设计软件。Adobe Photoshop中文版是Adobe Creative Cloud 创意云桌面程序中心的图形设计软件热门产品&#xff0c;它是平面设计领域和数字图象…

毕业2年,月薪就有30K,太卷了吧......

想起两年前交流过的一个应届生&#xff0c;当时他刚毕业技术水平不高&#xff0c;进了一个小公司做软件测试实习工作。最近联系上了&#xff0c;不问不知道&#xff0c;一问吓一跳&#xff0c;他现在已经进了某一线大厂&#xff0c;月薪30K。这位朋友其实也没比别人强多少&…

MySQL数据库从入门到精通学习第8天(表数据的查询)

表数据的查询 基本查询语句单表查询聚合函数查询多表连接查询子查询合并查询结果定义表和字段的别名使用正则表达式查询 基本查询语句 SELECT 语句非常的强大&#xff0c;是最常用的查询语句。他具有一个固定的格式&#xff0c;如下&#xff1a; SELECT 查询的内容 FROM 数据…

阿里P8大佬七天七夜制作这份自动化核心知识点,错过了就是错过了

整理了一份自动化核心知识点。覆盖了web前端基础&#xff0c;HTML标签&#xff0c;CSS样式&#xff0c;自动化测试工具&#xff0c;webdriver环境搭建&#xff0c;元素定位&#xff0c;手机操作系统&#xff0c;移动自动化测试工具&#xff0c;自动化测试的流程与分类&#xff…

requestAnimationFrame() 方法

[TOC](requestAnimationFrame() 方法) 一、基本使用 1.基本介绍 window.requestAnimationFrame() 主要是用来实现动画的时候使用的&#xff0c;不管是移动动画还是数字增长动画&#xff0c;使用这个api可以让你的动画看起来非常平滑&#xff0c;因为它是要求浏览器在下次重绘…

活动预告 | 中国数据库联盟(ACDU)中国行定档深圳,一起揭秘数据库前沿技术

在当今数字化时代&#xff0c;数据库是各行各业中最核心的信息管理系统之一。随着技术的飞速发展&#xff0c;数据库领域也不断涌现出新的前沿技术和创新应用。数据库运维和开发人员需要紧跟前沿技术&#xff0c;才能保持竞争力&#xff0c;并实现更高效、更智能、更人性化的应…

python使用requests+excel进行接口自动化测试(建议收藏)

前言 在当今的互联网时代中&#xff0c;接口自动化测试越来越成为软件测试的重要组成部分。Python是一种简单易学&#xff0c;高效且可扩展的语言&#xff0c;自然而然地成为了开发人员的首选开发语言。而requests和xlwt这两个常用的Python标准库&#xff0c;能够帮助我们轻松…

二十一、C++11(中)

文章目录 一、左值&右值&#xff08;一&#xff09;基本概念1.左值是什么2.右值是什么 &#xff08;二&#xff09;左值引用和右值引用1.左值引用2.右值引用 二、右值引用使用场景和意义&#xff08;一&#xff09;引入&#xff08;二&#xff09;左值引用的使用场景&#…