mainwindow.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QWidget>
  5. #include <QObject>
  6. #include <QThread>
  7. #include "Common/ccommon.h"
  8. class Core : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit Core(QObject *parent = nullptr);
  13. ~Core()
  14. {
  15. mWorkerThread.quit();
  16. mWorkerThread.wait();
  17. }
  18. // 定义供html页面调用的函数时,需要加上Q_INVOKABLE,否则html页面会找不到定义的函数
  19. Q_INVOKABLE void handleCmd(const QString &func, const QStringList &keys,
  20. const QStringList &values);
  21. signals:
  22. void operate(const int type, const QString &func, const QString &cmd);
  23. void operateResult(const QString &result);
  24. public slots:
  25. void handleResults(const RstData &rstData);
  26. private:
  27. QThread mWorkerThread;
  28. };
  29. QT_BEGIN_NAMESPACE
  30. namespace Ui { class MainWindow; }
  31. QT_END_NAMESPACE
  32. class MainWindow : public QMainWindow
  33. {
  34. Q_OBJECT
  35. public:
  36. MainWindow(QWidget *parent = nullptr);
  37. ~MainWindow();
  38. private:
  39. Ui::MainWindow *ui;
  40. Core mCore; // 定义全局的,否则程序运行会出错,js里面也找不到Core里面定义的函数
  41. };
  42. #endif // MAINWINDOW_H