add an example to embed a server in a Qt GUI app

This commit is contained in:
Chunting Gu
2021-01-22 11:34:17 +08:00
parent c3643277b2
commit 233aa5910c
7 changed files with 132 additions and 4 deletions
+34
View File
@@ -0,0 +1,34 @@
#ifndef MAIN_WINDOW_H_
#define MAIN_WINDOW_H_
#include <QMainWindow>
// Some global QObject with public signals for ApiView to inform the handling
// of client requests.
// "Context" is a bad name, you should change it.
class Context : public QObject {
Q_OBJECT
public:
explicit Context(QObject* parent = nullptr) : QObject(parent) {
}
// Public signals emitted from ApiView:
signals:
void SomeApiSignal(const QString& text);
// Add other signals here...
};
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(Context* context, QWidget* parent = nullptr);
private:
// You should encapsulate the required information as the signal parameters.
// I use QString just for demostrating how to transfer data from ApiView.
void OnSomeApiSignal(const QString& text);
};
#endif // MAIN_WINDOW_H_