Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
qtcpp_demo
提交
8dac734e
qtcpp_demo
项目概览
colorEagleStdio
/
qtcpp_demo
通知
465
Star
24
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qtcpp_demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8dac734e
编写于
3月 29, 2024
作者:
D
dev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
解决一个BUG,新的Qt更新后,template文件夹英也需要更新。这里不再为其准备图标。
同时测试tcp
上级
ac404bf3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
123 addition
and
36 deletion
+123
-36
android/sensors2pc/dlgstp.cpp
android/sensors2pc/dlgstp.cpp
+56
-10
android/sensors2pc/dlgstp.h
android/sensors2pc/dlgstp.h
+4
-0
android/sensors2pc/dlgstp.ui
android/sensors2pc/dlgstp.ui
+63
-26
未找到文件。
android/sensors2pc/dlgstp.cpp
浏览文件 @
8dac734e
...
...
@@ -3,12 +3,14 @@
#include <QHostAddress>
#include <QListView>
#include <QSettings>
#include <QDateTime>
#define MAX_ROWS_LSTV 256
DlgSTP
::
DlgSTP
(
QWidget
*
parent
)
:
QDialog
(
parent
)
,
ui
(
new
Ui
::
DlgSTP
)
,
m_pMsgMod
(
new
QStandardItemModel
(
this
))
,
m_psock
(
new
QUdpSocket
(
this
))
,
m_pstream
(
new
QTcpSocket
(
this
))
{
ui
->
setupUi
(
this
);
ui
->
listView_msg
->
setModel
(
m_pMsgMod
);
...
...
@@ -40,12 +42,36 @@ void DlgSTP::timerEvent(QTimerEvent * evt)
//Call Update functions
foreach
(
auto
fn
,
m_sensorUpdaters
)
fn
();
//Send Current Data
QHostAddress
addr
(
ui
->
lineEdit_ip
->
text
());
int
port
=
ui
->
spinBox_port
->
value
();
foreach
(
QString
i
,
m_listInfo
)
m_psock
->
writeDatagram
(
i
.
toLocal8Bit
(),
addr
,
port
);
m_nTotalSent
+=
m_listInfo
.
size
();
if
(
ui
->
checkBox_udp
->
isChecked
())
{
//Send Current Data
QHostAddress
addr
(
ui
->
lineEdit_ip_udp
->
text
());
int
port
=
ui
->
spinBox_port_udp
->
value
();
foreach
(
QString
i
,
m_listInfo
)
m_psock
->
writeDatagram
(
i
.
toLocal8Bit
(),
addr
,
port
);
m_nTotalSent
+=
m_listInfo
.
size
();
}
if
(
ui
->
checkBox_tcp
->
isChecked
())
{
if
(
m_pstream
->
state
()
==
QTcpSocket
::
ConnectedState
)
{
QTextStream
stm
(
m_pstream
);
stm
<<
"
\n
======
\n
"
;
stm
<<
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-ddTHH:mm:ss"
);
stm
<<
"
\n
"
;
foreach
(
QString
i
,
m_listInfo
)
{
stm
<<
i
<<
"
\n
"
;
}
m_nTotalSent
+=
m_listInfo
.
size
();
}
else
if
(
m_pstream
->
state
()
==
QTcpSocket
::
UnconnectedState
)
{
m_pstream
->
connectToHost
(
QHostAddress
(
ui
->
lineEdit_ip_tcp
->
text
()),
ui
->
spinBox_port_tcp
->
value
());
}
}
m_listInfo
.
clear
();
if
(
m_clk
%
updateGUI
==
0
)
{
...
...
@@ -184,18 +210,26 @@ void DlgSTP::on_pushButton_right_clicked()
void
DlgSTP
::
loadSettings
()
{
QSettings
settings
(
"ColoredEagleStudio"
,
"sensor2pc"
);
ui
->
lineEdit_ip
->
setText
(
settings
.
value
(
"ui/lineEdit_ip"
,
ui
->
lineEdit_ip
->
text
()).
toString
());
ui
->
spinBox_port
->
setValue
(
settings
.
value
(
"ui/spinBox_port"
,
ui
->
spinBox_port
->
value
()).
toInt
());
ui
->
lineEdit_ip_udp
->
setText
(
settings
.
value
(
"ui/lineEdit_ip_udp"
,
ui
->
lineEdit_ip_udp
->
text
()).
toString
());
ui
->
spinBox_port_udp
->
setValue
(
settings
.
value
(
"ui/spinBox_port_udp"
,
ui
->
spinBox_port_udp
->
value
()).
toInt
());
ui
->
lineEdit_ip_udp
->
setText
(
settings
.
value
(
"ui/lineEdit_ip_tcp"
,
ui
->
lineEdit_ip_tcp
->
text
()).
toString
());
ui
->
spinBox_port_udp
->
setValue
(
settings
.
value
(
"ui/spinBox_port_tcp"
,
ui
->
spinBox_port_tcp
->
value
()).
toInt
());
ui
->
horizontalSlider_freq
->
setValue
(
settings
.
value
(
"ui/horizontalSlider_freq"
,
ui
->
horizontalSlider_freq
->
value
()).
toInt
());
ui
->
horizontalSlider_gps
->
setValue
(
settings
.
value
(
"ui/horizontalSlider_gps"
,
ui
->
horizontalSlider_gps
->
value
()).
toInt
());
ui
->
checkBox_tcp
->
setChecked
(
settings
.
value
(
"ui/checkBox_tcp"
,
ui
->
checkBox_tcp
->
isChecked
()).
toBool
());
ui
->
checkBox_udp
->
setChecked
(
settings
.
value
(
"ui/checkBox_udp"
,
ui
->
checkBox_udp
->
isChecked
()).
toBool
());
}
void
DlgSTP
::
saveSettings
()
{
QSettings
settings
(
"ColoredEagleStudio"
,
"sensor2pc"
);
settings
.
setValue
(
"ui/lineEdit_ip"
,
ui
->
lineEdit_ip
->
text
());
settings
.
setValue
(
"ui/spinBox_port"
,
ui
->
spinBox_port
->
value
());
settings
.
setValue
(
"ui/lineEdit_ip_udp"
,
ui
->
lineEdit_ip_udp
->
text
());
settings
.
setValue
(
"ui/spinBox_port_udp"
,
ui
->
spinBox_port_udp
->
value
());
settings
.
setValue
(
"ui/lineEdit_ip_tcp"
,
ui
->
lineEdit_ip_udp
->
text
());
settings
.
setValue
(
"ui/spinBox_port_tcp"
,
ui
->
spinBox_port_udp
->
value
());
settings
.
setValue
(
"ui/horizontalSlider_freq"
,
ui
->
horizontalSlider_freq
->
value
());
settings
.
setValue
(
"ui/horizontalSlider_gps"
,
ui
->
horizontalSlider_gps
->
value
());
settings
.
setValue
(
"ui/checkBox_tcp"
,
ui
->
checkBox_tcp
->
isChecked
());
settings
.
setValue
(
"ui/checkBox_udp"
,
ui
->
checkBox_udp
->
isChecked
());
}
void
DlgSTP
::
on_horizontalSlider_gps_valueChanged
(
int
value
)
{
...
...
@@ -209,3 +243,15 @@ void DlgSTP::on_tabWidget_currentChanged(int index)
saveSettings
();
}
void
DlgSTP
::
on_checkBox_udp_clicked
(
bool
checked
)
{
saveSettings
();
}
void
DlgSTP
::
on_checkBox_tcp_clicked
(
bool
checked
)
{
saveSettings
();
}
android/sensors2pc/dlgstp.h
浏览文件 @
8dac734e
...
...
@@ -5,6 +5,7 @@
#include <QGeoPositionInfoSource>
#include <QStandardItemModel>
#include <QUdpSocket>
#include <QTcpSocket>
#include <QSensor>
#include <functional>
QT_BEGIN_NAMESPACE
...
...
@@ -39,11 +40,14 @@ protected:
protected:
//Net Send
QUdpSocket
*
m_psock
=
0
;
QTcpSocket
*
m_pstream
=
0
;
QStringList
m_listInfo
;
private
slots
:
void
on_pushButton_left_clicked
();
void
on_pushButton_right_clicked
();
void
on_horizontalSlider_gps_valueChanged
(
int
value
);
void
on_tabWidget_currentChanged
(
int
index
);
void
on_checkBox_udp_clicked
(
bool
checked
);
void
on_checkBox_tcp_clicked
(
bool
checked
);
};
#endif // DLGSTP_H
android/sensors2pc/dlgstp.ui
浏览文件 @
8dac734e
...
...
@@ -126,14 +126,14 @@ color: rgb(0, 0, 0);</string>
<item>
<widget
class=
"QGroupBox"
name=
"groupBox"
>
<property
name=
"title"
>
<string>
UDP
</string>
<string>
Network
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"1"
column=
"
1
"
>
<widget
class=
"QSpinBox"
name=
"spinBox_port"
>
<item
row=
"1"
column=
"
2
"
>
<widget
class=
"QSpinBox"
name=
"spinBox_port
_udp
"
>
<property
name=
"minimum"
>
<number>
1025
</number>
</property>
...
...
@@ -141,12 +141,33 @@ color: rgb(0, 0, 0);</string>
<number>
65536
</number>
</property>
<property
name=
"value"
>
<number>
3500
</number>
<number>
12345
</number>
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QSlider"
name=
"horizontalSlider_freq"
>
<item
row=
"5"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_5"
>
<property
name=
"text"
>
<string>
Sensor Update Interval
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"checkBox_tcp"
>
<property
name=
"text"
>
<string>
TCP
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"checkBox_udp"
>
<property
name=
"text"
>
<string>
UDP
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"2"
>
<widget
class=
"QSlider"
name=
"horizontalSlider_gps"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
...
...
@@ -176,31 +197,17 @@ color: rgb(0, 0, 0);</string>
</property>
</widget>
</item>
<item
row=
"
2
"
column=
"0"
>
<item
row=
"
4
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
GPS Update Interval
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Destin Address
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_5"
>
<property
name=
"text"
>
<string>
Sensor Update Interval
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"lineEdit_ip"
>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QLineEdit"
name=
"lineEdit_ip_tcp"
>
<property
name=
"text"
>
<string>
1
92.168.45.229
</string>
<string>
1
27.0.0.1
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
...
...
@@ -214,8 +221,8 @@ color: rgb(0, 0, 0);</string>
</property>
</widget>
</item>
<item
row=
"
2"
column=
"1
"
>
<widget
class=
"QSlider"
name=
"horizontalSlider_
gps
"
>
<item
row=
"
5"
column=
"2
"
>
<widget
class=
"QSlider"
name=
"horizontalSlider_
freq
"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
...
...
@@ -245,6 +252,36 @@ color: rgb(0, 0, 0);</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"2"
>
<widget
class=
"QLineEdit"
name=
"lineEdit_ip_udp"
>
<property
name=
"text"
>
<string>
127.0.0.1
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"text"
>
<string>
Destin Port
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
>
<widget
class=
"QSpinBox"
name=
"spinBox_port_tcp"
>
<property
name=
"minimum"
>
<number>
1025
</number>
</property>
<property
name=
"maximum"
>
<number>
65536
</number>
</property>
<property
name=
"value"
>
<number>
12345
</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录