Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rjosodtssp committed Apr 7, 2019
1 parent f42477f commit d76eaf8
Show file tree
Hide file tree
Showing 33 changed files with 2,404 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Qt-Websocket-client/main.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
63 changes: 63 additions & 0 deletions Qt-Websocket-client/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QJsonObject>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->textEdit->setFont(QFont("Consolas",18));
QUrl url = QUrl("ws://192.168.31.104:9090");
m_websocket.open(url);
QString err=m_websocket.errorString();
file = new QFile("/home/zzp/test.json");
file->open(QIODevice::ReadOnly);
if(err!="Unknown error")
ui->label->setText(err);
connect(&m_websocket,SIGNAL(connected()),this,SLOT(onconnected()));
connect(&m_websocket,SIGNAL(disconnected()),this,SLOT(ondisconnected()));
// connect(&m_websocket,SIGNAL(disconnected()),this,SLOT(closeConnection()));
}

MainWindow::~MainWindow()
{
delete ui;
}
//{
// id: "advertise:/cmd_vel:1"
// latch: false
// op: "advertise"
// queue_size: 100
// topic: "/cmd_vel"
// type: "geometry_msgs/Twist"
//}

//{
// "op":"publish",
// "id":"publish:/cmd_vel:2",
// "topic":"/cmd_vel",
// "msg":{"linear":{"x":0.1,"y":0,"z":0},
// "angular":{"x":0,"y":0,"z":0}},
// "latch":false
// }
void MainWindow::on_pushButton_clicked()
{
QString msg = ui->textEdit->document()->toPlainText();
m_websocket.sendTextMessage(msg);
// QTextStream stream(file);
// QString data = stream.readAll();
// qDebug()<<data;
// m_websocket.sendTextMessage(data);
}

void MainWindow::onconnected()
{
ui->label->setText(QStringLiteral("连接成功!"));
}

void MainWindow::ondisconnected()
{
ui->label->setText(QStringLiteral("未连接!"));
}
33 changes: 33 additions & 0 deletions Qt-Websocket-client/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtWebSockets/QtWebSockets>
#include <QFile>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_pushButton_clicked();
public slots:
void onconnected();
void ondisconnected();

private:
Ui::MainWindow *ui;
QUrl m_url;
QWebSocket m_websocket;
QFile* file;
};

#endif // MAINWINDOW_H
59 changes: 59 additions & 0 deletions Qt-Websocket-client/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>624</width>
<height>519</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>25</number>
</property>
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>55</number>
</property>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>发送消息</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
34 changes: 34 additions & 0 deletions Qt-Websocket-client/untitled.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-10-24T20:44:18
#
#-------------------------------------------------

QT += core gui websockets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has 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
Loading

0 comments on commit d76eaf8

Please sign in to comment.