libgitlevtbus基于Qt的Event Bus

联合创作 · 2023-09-28 18:42

libgitlevtbus 是基于Qt构建的事件总线库,利用了Qt中的signal和slot机制,具有易于使用的优点。



#include "gitlmodual.h"
#include "gitleventbus.h"
#include <QDebug>

/*!
* This is a test modual
*/
class TestModual : public GitlModual
{
public:
/// re-implement this method to do anything you want...
virtual bool detonate( GitlEvent& rcEvt)
{
qDebug() << "I got notified!";
return true;
}
};


int main(int argc, char *argv[])
{
TestModual cModual;
cModual.subscribeToEvtByName("I am a test event"); ///< subscribe to an event

GitlEvent cEvent("I am a test event"); ///< create an event
cEvent.dispatch(); ///< dispatch

///< output: "I got notified!"     
    
    return 0;
}
浏览 70
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报