#ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include #include #include "Common/ccommon.h" class Core : public QObject { Q_OBJECT public: explicit Core(QObject *parent = nullptr); ~Core() { mWorkerThread.quit(); mWorkerThread.wait(); } // 定义供html页面调用的函数时,需要加上Q_INVOKABLE,否则html页面会找不到定义的函数 Q_INVOKABLE void handleCmd(const QString &func, const QStringList &keys, const QStringList &values); signals: void operate(const int type, const QString &func, const QString &cmd); void operateResult(const QString &result); public slots: void handleResults(const RstData &rstData); private: QThread mWorkerThread; }; QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private: Ui::MainWindow *ui; Core mCore; // 定义全局的,否则程序运行会出错,js里面也找不到Core里面定义的函数 }; #endif // MAINWINDOW_H