#include "control.h"
#include <qdebug.h>
#include <QMessageBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QTime>
/* 外部变量,定义在BLE.cpp里 蓝牙连接成功后的socket */
Control::Control(int w, int h, QTabWidget *parent) :
QTabWidget(parent)
{
// BTE = new BlueTooth(w,h);
this->setFixedSize(w,h);
QFont titleFont;//标题文字字体
titleFont.setPointSize(25);
//titleFont.setBold(true);
setFont(titleFont);
for(int i = 0;i<30;i++){
classroom.sit[i] = 0;
}
QWidget *wnd1 = new QWidget;
QWidget *wnd2 = new QWidget;
QWidget *wnd3 = new QWidget;
wnd1->setFont(titleFont);
wnd2->setFont(titleFont);
this->addTab(wnd1,"教室设置");
this->addTab(wnd2,"参数输入");
this->addTab(wnd3,"聊天窗口");
//-----------------------------------------------------wnd1
floorCob = new QComboBox;
floorCob->addItems( QStringList()<<tr("1层")
<<tr("2层")<<tr("3层")<<tr("4层")<<tr("5层") );
floorCob->setCurrentIndex(0);
floorCob->setFixedSize(0.35*w,0.07*h);
classroomCob = new QComboBox;
classroomCob->addItems( QStringList()<<tr("101")
<<tr("102")<<tr("103")<<tr("104")<<tr("105") );
classroomCob->setCurrentIndex(0);
classroomCob->setFixedSize(0.35 *w,0.07*h);
QPushButton *backbtn = new QPushButton;
backbtn->setText("返回");
backbtn->setFixedSize(0.2 *w,0.07*h);
connect(floorCob, SIGNAL(currentIndexChanged(int)), this, SLOT(changeFloor(int)));
connect(classroomCob, SIGNAL(currentIndexChanged(int)), this, SLOT(changeClassroom(int)));
connect(backbtn, SIGNAL(clicked( )), this, SLOT(on_pushButton_back_clicked( )));
QHBoxLayout *comlay = new QHBoxLayout;
comlay->addWidget(floorCob);
comlay->addWidget(classroomCob);
comlay->addWidget(backbtn);
QVBoxLayout *sitlay_v = new QVBoxLayout;
for(int i = 0;i<6;i++){
QHBoxLayout *sitlay_h = new QHBoxLayout;
for(int j = 0;j<5;j++){
sit[i][j] = new topmenubtn;
sitlay_h->addWidget(sit[i][j]);
sit[i][j]->setFixedSize(0.98*w*0.18,0.88*h/7);
sit[i][j]->setFont(titleFont);
sit[i][j]->setText(QString("%1").arg(i*5+j+1));
sit[i][j]->setAlignment( Qt::AlignCenter|Qt::AlignVCenter );//
sit[i][j]->setStyleSheet("background-color:rgb(252,227,239);");
connect(sit[i][j], SIGNAL(Clicked( )), this, SLOT(chooseSit( )));
}
sitlay_v->addLayout(sitlay_h);
sitlay_v->setMargin(0);
}
QVBoxLayout *ALL1 = new QVBoxLayout;
ALL1->addLayout(comlay);
ALL1->addLayout(sitlay_v);
ALL1->addStretch();
ALL1->setMargin(0);
wnd1->setLayout(ALL1);
//-----------------------------------------------------wnd2
QLabel *na1 = new QLabel;
na1->setText("设置温度:");
na1->setFixedSize(0.4 *w,0.1*h);
QLabel *na11 = new QLabel;
na11->setText("℃");
na11->setFixedSize(0.1 *w,0.1*h);
TEM_led = new QLineEdit;
TEM_led->setFixedSize(0.4 *w,0.1*h);
connect(TEM_led, SIGNAL(textEdited(QString)), this, SLOT(changetemp(QString)));
QHBoxLayout *set1_h = new QHBoxLayout;
set1_h->addWidget(na1);
set1_h->addWidget(TEM_led);
set1_h->addWidget(na11);
QLabel *na2 = new QLabel;
na2->setText("设置风速:");
na2->setFixedSize(0.4 *w,0.1*h);
QLabel *na21 = new QLabel;
na21->setText("米/秒");
na21->setFixedSize(0.1 *w,0.1*h);
windspd_led = new QLineEdit;
connect(windspd_led, SIGNAL(textEdited(QString)), this, SLOT(changewindspd(QString)));
windspd_led->setFixedSize(0.4 *w,0.1*h);
QHBoxLayout *set2_h = new QHBoxLayout;
set2_h->addWidget(na2);
set2_h->addWidget(windspd_led);
set2_h->addWidget(na21);
QLabel *na3 = new QLabel;
na3->setText("设置时间:");
na3->setFixedSize(0.4 *w,0.1*h);
timeCob_h = new QComboBox;
timeCob_h->addItems( QStringList()<<tr("00:00")<<tr("01:00")<<tr("02:00")<<tr("03:00")<<tr("04:00")<<tr("05:00")<<tr("06:00")<<tr("07:00")<<tr("08:00")<<tr("09:00")<<tr("10:00")<<tr("11:00")<<tr("12:00") <<tr("13:00") <<tr("14:00")<<tr("15:00")<<tr("16:00")<<tr("17:00")<<tr("18:00")<<tr("19:00")<<tr("20:00")<<tr("21:00")<<tr("22:00")<<tr("23:00") );
timeCob_h->setCurrentIndex(0);
timeCob_h->setFixedSize(0.5 *w,0.1*h);
connect(timeCob_h, SIGNAL(currentIndexChanged(int)), this, SLOT(changeclock(int)));
QHBoxLayout *set3_h = new QHBoxLayout;
set3_h->addWidget(na3);
set3_h->addWidget(timeCob_h);
QLabel *na4 = new QLabel;
na4->setText("设置月份:");
na4->setFixedSize(0.4 *w,0.1*h);
monthCob = new QComboBox;
monthCob->addItems( QStringList()<<tr("1月")<<tr("2月")<<tr("3月")<<tr("4月")<<tr("5月")<<tr("6月")<<tr("7月")<<tr("8月")<<tr("9月")<<tr("10月")<<tr("11月") <<tr("12月") );
monthCob->setCurrentIndex(0);
connect(monthCob, SIGNAL(currentIndexChanged(int)), this, SLOT(changemonth(int)));
monthCob->setFixedSize(0.5 *w,0.1*h);
QHBoxLayout *set4_h = new QHBoxLayout;
set4_h->addWidget(na4);
set4_h->addWidget(monthCob);
QLabel *na5 = new QLabel;
na5->setText("设置天气:");
na5->setFixedSize(0.4 *w,0.1*h);
weatherCob = new QComboBox;
weatherCob->addItems( QStringList()<<tr("晴天")
<<tr("阴天") );
connect(weatherCob, SIGNAL(currentIndexChanged(int)), this, SLOT(changeweather(int)));
weatherCob->setCurrentIndex(0);
weatherCob->setFixedSize(0.5 *w,0.1*h);
QHBoxLayout *set5_h = new QHBoxLayout;
set5_h->addWidget(na5);
set5_h->addWidget(weatherCob);
QPushButton *backbtn1 = new QPushButton;
backbtn1->setText("返回");
backbtn1->setFixedSize(0.8 *w,0.1*h);
connect(backbtn1, SIGNAL(clicked( )), this, SLOT(on_pushButton_back_clicked( )));
QHBoxLayout *set6_h = new QHBoxLayout;
set6_h->addStretch(1);
set6_h->addWidget(backbtn1);
set6_h->addStretch(1);
QVBoxLayout *ALL2 = new QVBoxLayout;
ALL2->addLayout(set1_h);
ALL2->addLayout(set2_h);
ALL2->addLayout(set3_h);
ALL2->addLayout(set4_h);
ALL2->addLayout(set5_h);
ALL2->addLayout(set6_h);
wnd2->setLayout(ALL2);
//-----------------------------------------------------wnd3
MsgLed = new QPlainTextEdit;
MsgLed->setFixedSize(0.98*w,0.4*h);
SendLed = new QLineEdit;
SendLed->setFixedSize(0.98*w,0.2*h);
QPushButton *sendBtn = new QPushButton;
sendBtn->setFixedSize(0.35*w,0.1*h);
sendBtn->setText("发送");
connect(sendBtn, SIGNAL(clicked( )), this, SLOT(on_sendbtn_click( )));
QPushButton *clearBtn = new QPushButton;
clearBtn->setFixedSize(0.35*w,0.1*h);
clearBtn->setText("清除");
connect(clearBtn, SIGNAL(clicked( )), this, SLOT(on_clearbtn_click( )));
QHBoxLayout *hh_h = new QHBoxLayout;
hh_h->addStretch(1);
hh_h->addWidget(sendBtn);
hh_h->addWidget(clearBtn);
hh_h->addStretch(1);
QVBoxLayout *ALL3 = new QVBoxLayout;
ALL3->addWidget(MsgLed);
ALL3->addWidget(SendLed);
ALL3->addLayout(hh_h);
wnd3->setLayout(ALL3);
}
Control::~Control()
{
}
bool Control::blueStates()
{
// if( socket == NULL)
// {
// QMessageBox::information(this, "错误", "蓝牙未连接");
// return false;
// }
// else
return true;
}
void Control::receiveMsg(QString msg)
{
QTime current_time =QTime::currentTime();
int hour = current_time.hour();//当前的小时
int minute = current_time.minute();//当前的分
int second = current_time.second();//当前的秒QString
QString h
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
QT 蓝牙通信.zip (34个子文件)
QT 蓝牙通信
服务器
smartHousePC
smartHousePC.pro.user 33KB
control.h 2KB
topmenubtn.h 392B
dialog.cpp 187B
smartHousePC.pro 597B
bluetooth.cpp 10KB
dialog.h 251B
bluetooth.h 2KB
main.cpp 427B
mainwindow.ui 630B
mainwindow.cpp 3KB
dialog.ui 1KB
mainwindow.h 720B
topmenubtn.cpp 371B
control.cpp 9KB
.DS_Store 6KB
.DS_Store 6KB
客户端
.DS_Store 6KB
smartHouse
control.h 2KB
topmenubtn.h 392B
bluetooth.cpp 6KB
control.ui 405B
form.ui 399B
bluetooth.h 1KB
main.cpp 330B
mainwindow.ui 507B
smartHouse.pro.user 68KB
smartHouse.pro 538B
mainwindow.cpp 3KB
mainwindow.h 720B
topmenubtn.cpp 371B
smartHouse.pro.user.b36c39a 48KB
form.cpp.autosave 191B
control.cpp 12KB
共 34 条
- 1
资源评论
- dahanzk2019-10-25都不是QT的代码。也不能用小心骗子梁道永2020-04-24明明就是用qt平台写的软件。只要用qt for android 模块把软件安装到手机 可以和电脑进行蓝牙通信到。如果不行到话 你点举报把 我也不想骗人,让系统来审核把
梁道永
- 粉丝: 17
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功