1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <QWidget>
- #include <QObject>
- #include <QThread>
- #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
|