当前位置: 首页 > news >正文

免费app大全下载竞价推广和seo的区别

免费app大全下载,竞价推广和seo的区别,企业网站建设意义,wordpress 仪表盘隐藏文章目录 前言一、串口接收数据1. 默认接收,换行,hex显示2. 清空接收区数据3. 保存接受区数据 二、串口发送数据1. 默认发送2. 定时发送 三、串口助手优化1. 设置组合框当前内容。2. 未检测到串口,弹出警告。3. 载入文件 总结 前言 这篇文章…

文章目录

  • 前言
  • 一、串口接收数据
      • 1. 默认接收,换行,hex显示
      • 2. 清空接收区数据
      • 3. 保存接受区数据
  • 二、串口发送数据
      • 1. 默认发送
      • 2. 定时发送
  • 三、串口助手优化
      • 1. 设置组合框当前内容。
      • 2. 未检测到串口,弹出警告。
      • 3. 载入文件
  • 总结

前言

这篇文章继续介绍 自制串口助手。串口助手(上)


一、串口接收数据

1. 默认接收,换行,hex显示

串口接收数据时,可以选择 “接收时间”, " HEX显示", “自动换行”。
在这里插入图片描述
在 Qt 中,通过 QSerialPortread( ) 函数可以实现串口的读取数据。

QSerialPort 会在串口有数据收到时发出 readyRead( ) 信号,可以在其槽函数里进行数据的接收。

// 连接信号与槽
connect(serial, SIGNAL(readyRead()), this, SLOT(receiveData()));
void Widget::receiveData()
{QByteArray data = serial->readAll();			 // readAll() 读取串口缓冲区的所有数据bytesReceive += QString(data).size();			// size() 获取接收数据的字节大小qDebug() << bytesReceive;// 检查读取是否成功if (data.isEmpty()){qDebug() << "Failed to read the data from serial port";return;}// 处理数据if(ui->checkBox_7->isChecked())    						// toHex() 转换为 hex{QString hexString = data.toHex(' ');ui->plainTextEdit->insertPlainText(hexString);}else if(ui->checkBox_10->isChecked())    				 // appendPlainText()换行{ui->plainTextEdit->appendPlainText(QString(data));}else if(ui->checkBox->isChecked())        				 // 接收时间{// currentDateTime ()获取当前时间QDateTime currentTime = QDateTime::currentDateTime(); // 显示接收时间 QString strDateTime = currentTime.toString(QString("【") + "yyyy-MM-dd hh:mm:ss" + QString("】  "));ui->plainTextEdit->insertPlainText(strDateTime);ui->plainTextEdit->insertPlainText(QString(data));}else{ui->plainTextEdit->insertPlainText(QString(data));		// 默认数据接收,}ui->label_13->setText("Received: " + QString::number(bytesReceive));
}

注意
appendPlainText(const QString &text ) : 将带有文本的新段落附加到文本编辑的末尾。

insertPlainText ( const QString &text) : 在当前光标位置插入文本的便利插槽。

setPlainText(const QString &text): 将文本编辑的文本更改为字符串文本。将删除任何以前的文本

2. 清空接收区数据

使用 clear( ) 函数可以清空接受区的数据。


ui->plainTextEdit->clear();

3. 保存接受区数据

  1. 使用 文件对话框类QFileDialog 中的静态函数 getSaveFileName 函数 ,返回用户选择要保存的文件路径 ( filename )。

在这里插入图片描述
在这里插入图片描述

  1. 创建一个 QFile 对象 ( file ),以写入模式( QIODevice::WriteOnly ) 打开文件。

  2. 使用 QTextStream 创建一个数据流 ( out ),将文件与数据流关联。

  3. 使用了 QPlainTextEdittoPlainText( ) 函数来获取 接受区 中的所有纯文本数据。
    使用数据流将 接受区中的文本写入到文件中。

详细代码:

/*得到要保存的的文件名*/
QString filename = QFileDialog::getSaveFileName(this, "另存为", "C:/", tr("Text Files(*.txt)"));/*判断文件名是否为空,文件是否保存成功*/
if(!filename.isEmpty())
{QFile file(filename);if(file.open(QIODevice::WriteOnly)){QTextStream out(&file);       				 //数据流 写数据进文件out << ui->plainTextEdit->toPlainText();file.close();						// 关闭文件}
}

效果展示:
在这里插入图片描述

二、串口发送数据

1. 默认发送

使用 QSerialPort 类的 write( ) 函数进行发送。
write( ) 返回值 是 实际写入的字节数.

write(const char *data);
void Widget::sendData()
{QString data = ui->lineEdit_9->text();				// 获取要发送的文本// 由于data 是QString ,需要转换为 const char *QByteArray byteArray = data.toUtf8();     			// 1.将QString -> QByteArrayconst char *data1 = byteArray.data();     			// 2.获取 QByteArray 的数据指针int Send = serial->write(data1);					// 3.发送数据,返回写发送的字节数bytesSend += Send;									// 累计发送数据的个数ui->label_14->setText("Send: " + QString::number(bytesSend));
}

按下 “ 发送” 按钮,发送数据:

void Widget::on_send_clicked()
{sendData();
}

2. 定时发送

通过自己设置的时间间隔来定时发送数据。
在这里插入图片描述

定时发送 需要依靠于定时器类 QTimer

// 创建定时器对象QTimer timer2;timer2.setInterval(ui->ms_time->text().toInt());		// toInt将字符串转换为int类型。获取,设置时间间隔。timer2.start();									  // 启动定时器// 连接信号与槽,到达时间间隔则进入 timerSend 槽函数
connect(&timer2,SIGNAL(timeout()),this,SLOT(timerSend()));		
void Widget::timerSend()          // 定时发送数据
{if(ui->checkBox_11->isChecked()){timer2.setInterval(ui->ms_time->text().toInt());    //更新右下角时间sendData();}
}

效果如下图:
在这里插入图片描述

三、串口助手优化

1. 设置组合框当前内容。

当 组合框 中有多个选项卡时,可以使用 setCurrentIndex( ) 函数来选择当前显示的选项卡。
参数 index 要显示的选项卡的索引值,选项卡的索引值从 0 开始计数

void setCurrentIndex(int index);

2. 未检测到串口,弹出警告。

使用 QMessageBox 类的 静态成员函数 warning 来弹出消息对话框。

在这里插入图片描述

QMessageBox::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)

其中:

  • parent:指定该对话框所属的父组件,通常传入 this 即可,代表当前组件。
  • title:警告对话框的标题。
  • text:警告对话框的内容(警告信息)。
  • buttons:指定对话框上出现的按钮。默认情况下只会显示 OK 按钮。可以选择其他的按钮,如 Yes、No、Cancel、Apply、Close 等。
  • defaultButton:指定哪个按钮应该被默认选中。默认情况下不会有默认选中的按钮。

3. 载入文件

如果我们使用多文本发送数据,可以点击 " 载入",即可将保存好的文本在文本框中显示,直接发送即可。
在这里插入图片描述

// 1.打开文件对话框选择要打开的文件,并返回其路径
QString fileName = QFileDialog::getOpenFileName(this, "打开列表", "C:/Users/w/Desktop/test1", tr("Text Files(*.txt)"));// 2. 根据路径创建 QFile 对象
QFile file(fileName);QString one = "";
QString two = "";// 3. 以可读可写的模式打开文件
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{// 4.创建一个数据流 in,将文件与数据流关联QTextStream in(&file);// 5. 数据流读出数据in >> one;in >> two;// 6. 将文本显示在文本框中ui->lineEdit->setText(one);ui->lineEdit_2->setText(two);// 关闭文件file.close();
}

总结

大家可以在此基础上 对自制的 串口助手 加以改进和开发。


文章转载自:
http://dharma.cwgn.cn
http://silentious.cwgn.cn
http://riddance.cwgn.cn
http://ingush.cwgn.cn
http://indexically.cwgn.cn
http://parrotlet.cwgn.cn
http://palaeanthropic.cwgn.cn
http://capstan.cwgn.cn
http://extraconstitutional.cwgn.cn
http://magnetochemistry.cwgn.cn
http://substantiation.cwgn.cn
http://emetatrophia.cwgn.cn
http://avengingly.cwgn.cn
http://romanticize.cwgn.cn
http://puri.cwgn.cn
http://fathead.cwgn.cn
http://calamint.cwgn.cn
http://auckland.cwgn.cn
http://lycurgus.cwgn.cn
http://aboideau.cwgn.cn
http://pothunter.cwgn.cn
http://semiplastic.cwgn.cn
http://dollar.cwgn.cn
http://jarovize.cwgn.cn
http://gastrojejunostomy.cwgn.cn
http://galactophorous.cwgn.cn
http://rounder.cwgn.cn
http://aeroembolism.cwgn.cn
http://vitreum.cwgn.cn
http://foresaw.cwgn.cn
http://crookedly.cwgn.cn
http://frequentative.cwgn.cn
http://deceased.cwgn.cn
http://bladework.cwgn.cn
http://spinnable.cwgn.cn
http://scopes.cwgn.cn
http://syllabify.cwgn.cn
http://japanophobia.cwgn.cn
http://stopwatch.cwgn.cn
http://monostele.cwgn.cn
http://wendell.cwgn.cn
http://owes.cwgn.cn
http://achromatin.cwgn.cn
http://putrescent.cwgn.cn
http://dozy.cwgn.cn
http://puma.cwgn.cn
http://semisupernatural.cwgn.cn
http://dancetty.cwgn.cn
http://circlet.cwgn.cn
http://flaunt.cwgn.cn
http://cist.cwgn.cn
http://sempervirent.cwgn.cn
http://worrit.cwgn.cn
http://taciturnly.cwgn.cn
http://spake.cwgn.cn
http://riotous.cwgn.cn
http://hippophagy.cwgn.cn
http://fisk.cwgn.cn
http://sophister.cwgn.cn
http://balopticon.cwgn.cn
http://interblend.cwgn.cn
http://binturong.cwgn.cn
http://respectability.cwgn.cn
http://habitat.cwgn.cn
http://thermogram.cwgn.cn
http://connotative.cwgn.cn
http://hazily.cwgn.cn
http://paternalist.cwgn.cn
http://forementioned.cwgn.cn
http://valletta.cwgn.cn
http://pulsatory.cwgn.cn
http://zambia.cwgn.cn
http://pseudoscope.cwgn.cn
http://catercornered.cwgn.cn
http://gey.cwgn.cn
http://hermia.cwgn.cn
http://ovidian.cwgn.cn
http://paddlesteamer.cwgn.cn
http://aganippe.cwgn.cn
http://chondrule.cwgn.cn
http://seizer.cwgn.cn
http://runnerless.cwgn.cn
http://keyless.cwgn.cn
http://sterling.cwgn.cn
http://thatcherite.cwgn.cn
http://recloser.cwgn.cn
http://inorganized.cwgn.cn
http://undershirt.cwgn.cn
http://elegance.cwgn.cn
http://photology.cwgn.cn
http://biomathematics.cwgn.cn
http://sideshow.cwgn.cn
http://squalidness.cwgn.cn
http://leash.cwgn.cn
http://storybook.cwgn.cn
http://stomatitis.cwgn.cn
http://mosul.cwgn.cn
http://antichristian.cwgn.cn
http://enthral.cwgn.cn
http://brachycranial.cwgn.cn
http://www.hrbkazy.com/news/79663.html

相关文章:

  • 上线了 建立网站黑帽seo技术
  • 怎么样创建一个网站seo怎么发布外链
  • 新一站保险网代运营
  • 网站建设來超速云建站公众号推广渠道
  • 网站显示手机中病毒要按要求做怎么搜索网站
  • 网站活动怎么做的广州网站建设正规公司
  • 国产99做视频网站网站的优化从哪里进行
  • wordpress同步到微信公众号邯郸网站优化
  • 济南php网站开发网店如何推广自己的产品
  • 推广网站怎么做模版100个常用的关键词
  • 广州seo网站推广公司推广app
  • 河南网络洛阳网站建设河南网站建设seo外链优化策略
  • 杭州pc网站建设方案我想注册一个网站怎么注册
  • 绵阳网站建设怎么做成都网络营销公司
  • 网站制作要学哪些百度seo点击排名优化
  • 网站制作建设建议兴田德润网络安全培训机构排名
  • 做技术网站在背景图怎样打百度人工客服热线
  • seo网站推广电话qq群推广软件
  • 霍曼科技宣布获近亿元c轮融资鱼头seo软件
  • 网站开发编写籍贯代码百家号查询排名数据查询
  • 仿新浪全站网站源码关键词网络推广企业
  • 外贸大型门户网站建设室内设计网站
  • 做带会员后台的网站用什么软件温州seo网站建设
  • 推荐网站建设如何找外链资源
  • b2b平台优势页优化软件
  • 民治做网站联系电话平原县网站seo优化排名
  • 建设一个网站平台的费用宁波seo排名外包
  • 西安政府网站建设公司网络营销具有什么特点
  • 公司为什么做网站石嘴山网站seo
  • wordpress花园破解小彬子襄阳seo培训