#ifndef MESSAGEQUEUE_H #define MESSAGEQUEUE_H #include #include #include #include "qdebug.h" class MessageQueue : public QObject { Q_OBJECT public: explicit MessageQueue(QObject *parent = nullptr) : QObject(parent) , isProcessing(false) {} // 向队列中添加消息 void addMessage(const QString &text, const QVariant &messageBoxPointX, const QVariant &messageBoxPointY, const QVariant &messageTitle) { qDebug() << text << messageBoxPointX << messageBoxPointY << messageTitle; this->messageBoxPointX = messageBoxPointX; this->messageBoxPointY = messageBoxPointY; this->messageTitle = messageTitle; messageQueue.enqueue(text); processQueue(); } private: QQueue messageQueue; bool isProcessing; // 处理队列中的消息 void processQueue(); QVariant messageBoxPointX; QVariant messageBoxPointY; QVariant messageTitle; private slots: // 当消息框关闭时,继续处理队列中的下一个消息 void onMessageBoxClosed() { isProcessing = false; processQueue(); } }; #endif // MESSAGEQUEUE_H