//ex2.cpp
#include "ex2.h"
#include "ui_ex2.h"
#include <QtSerialPort/QtSerialPort>
int static cnt = 0;
Ex2::Ex2(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Ex2)
{
ui->setupUi(this);
}
Ex2::~Ex2()
{
delete ui;
}
void Ex2::on_pushButtonMy1_clicked()
{
cnt ++;
QString str = QString::number(cnt,10);
ui->textEditMy1->setText(str);
}
void Ex2::on_pushButtonMy2_clicked()
{
if(cnt > 0) cnt --;
QString str = QString::number(cnt,10);
ui->textEditMy1->setText(str);
}
void Ex2::on_pushButtonClr_clicked()
{
ui->textEditMy1->setText("");
}
void Ex2::on_pushButtonComm_clicked()
{
QList<QSerialPortInfo> list = QSerialPortInfo::availablePorts();
ui->textEditMy1->setText("Total number of availiable ports:" + QString::number(list.count(), 10));
foreach(const QSerialPortInfo &serialportinfo, list)
{
ui->textEditMy1->append( "===========================================");
ui->textEditMy1->append( "Port: " + serialportinfo.portName());
ui->textEditMy1->append( "Location: " + serialportinfo.systemLocation());
ui->textEditMy1->append( "Description: " + serialportinfo.description());
ui->textEditMy1->append( "Manufactutor: " + serialportinfo.manufacturer());
ui->textEditMy1->append( "Vendor Indentifier: " + QString::number(serialportinfo.vendorIdentifier(), 10));
ui->textEditMy1->append( "Busy: " + QString::number(serialportinfo.isBusy()));
}
}
文章来源地址https://www.toymoban.com/news/detail-621144.html
文章来源:https://www.toymoban.com/news/detail-621144.html
到了这里,关于Qt 3. QSerialPortInfo显示串口信息在QTextEdit显示的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!