summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2017-01-19 13:09:33 +0100
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-01-19 13:09:33 +0100
commit50b5230a579f360423c38576ce08744c96cf1517 (patch)
tree715c0c5415642393c234f6ed01d2c01a3647c5a6 /examples
parentded87ab1b5aa524ab36aeb2339d4db8668fdf579 (diff)
Add example app to get started
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/mqtt/mqtt.pro2
-rw-r--r--examples/mqtt/simpleclient/main.cpp11
-rw-r--r--examples/mqtt/simpleclient/mainwindow.cpp35
-rw-r--r--examples/mqtt/simpleclient/mainwindow.h29
-rw-r--r--examples/mqtt/simpleclient/mainwindow.ui57
-rw-r--r--examples/mqtt/simpleclient/simpleclient.pro27
7 files changed, 163 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 0000000..9fbc61f
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += mqtt
diff --git a/examples/mqtt/mqtt.pro b/examples/mqtt/mqtt.pro
new file mode 100644
index 0000000..48c182b
--- /dev/null
+++ b/examples/mqtt/mqtt.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += simpleclient
diff --git a/examples/mqtt/simpleclient/main.cpp b/examples/mqtt/simpleclient/main.cpp
new file mode 100644
index 0000000..b48f94e
--- /dev/null
+++ b/examples/mqtt/simpleclient/main.cpp
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/mqtt/simpleclient/mainwindow.cpp b/examples/mqtt/simpleclient/mainwindow.cpp
new file mode 100644
index 0000000..4f296e7
--- /dev/null
+++ b/examples/mqtt/simpleclient/mainwindow.cpp
@@ -0,0 +1,35 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QtMqtt/QMqttClient>
+
+// http://test.mosquitto.org/
+//const QString TEST_HOST("test.mosquitto.org");
+const QString TEST_HOST("hostprocess.de");
+const quint16 TEST_PORT = 1883;
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ m_client = new QMqttClient(this);
+ m_client->setHostname(TEST_HOST);
+ m_client->setPort(TEST_PORT);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::on_buttonConnect_clicked()
+{
+ m_client->connectToHost();
+}
+
+void MainWindow::on_buttonQuit_clicked()
+{
+ QApplication::quit();
+}
diff --git a/examples/mqtt/simpleclient/mainwindow.h b/examples/mqtt/simpleclient/mainwindow.h
new file mode 100644
index 0000000..df4715d
--- /dev/null
+++ b/examples/mqtt/simpleclient/mainwindow.h
@@ -0,0 +1,29 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QTcpSocket>
+#include <QtMqtt/QMqttClient>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private slots:
+ void on_buttonConnect_clicked();
+ void on_buttonQuit_clicked();
+
+private:
+ Ui::MainWindow *ui;
+ QMqttClient *m_client;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/mqtt/simpleclient/mainwindow.ui b/examples/mqtt/simpleclient/mainwindow.ui
new file mode 100644
index 0000000..a99ed1a
--- /dev/null
+++ b/examples/mqtt/simpleclient/mainwindow.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="buttonConnect">
+ <property name="text">
+ <string>Connect</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonQuit">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/mqtt/simpleclient/simpleclient.pro b/examples/mqtt/simpleclient/simpleclient.pro
new file mode 100644
index 0000000..805e33c
--- /dev/null
+++ b/examples/mqtt/simpleclient/simpleclient.pro
@@ -0,0 +1,27 @@
+QT += core gui network mqtt
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = mqcheck
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+FORMS += mainwindow.ui
+
+target.path = $$[QT_INSTALL_EXAMPLES]/mqtt/simpleclient
+INSTALLS += target