#pragma once #include #include namespace Psc { template class Delegate { public: QVector handlers; Delegate& operator+=(const Handler_Type& handler) { if (std::find(handlers.begin(), handlers.end(), handler) == handlers.end()) { handlers.push_back(handler); } return *this; } Delegate& operator-=(const Handler_Type& handler) { auto it = std::find(handlers.begin(), handlers.end(), handler); if (it != handlers.end()) { handlers.erase(it); // 移除对应的处理程序 } return *this; } template void invoke(Args&&... args) const { for (auto& handler : handlers) { handler(std::forward(args)...); // 完美转发参数 } } }; using MousePressEvent_Handler = std::function; }