linux系统管理客户端1--串口配置代码编写
2014-06-12 15:03
686 查看
1、下载qextserialport-1.2win-alpha.zip
2、自定义串口配置类(comDialog:以备主界面调用)
3、UI需要自己定义
2、自定义串口配置类(comDialog:以备主界面调用)
3、UI需要自己定义
//自定义类的头文件: //////////////////////////////////////////////////////////////////////// #ifndef COMDIALOG_H #define COMDIALOG_H #include namespace Ui { class comDialog; } class comDialog : public QDialog { Q_OBJECT public: explicit comDialog(QWidget *parent = 0); ~comDialog(); private: Ui::comDialog *ui; private: void getCom(); //获取当前机器的可用端口函 private slots: void clickCommitButton(); //确定按钮槽函数 void clickCancleButton(); //取消按钮槽函数 void clickBackButton(); //恢复默认函数 public: QString comPort; int comBaud; int comStopBit; int comDataBit; int comPariy; int comFlow; }; #endif // COMDIALOG_H //自定义类的源文件: //////////////////////////////////////////////////////////////////////// #include "comdialog.h" #include "ui_comdialog.h" #include comDialog::comDialog(QWidget *parent) : QDialog(parent), ui(new Ui::comDialog) { ui->setupUi(this); getCom(); ui->commitButton->setDefault(true); connect(ui->commitButton,SIGNAL(clicked()),this,SLOT(clickCommitButton())); connect(ui->cancleButton,SIGNAL(clicked()),this,SLOT(clickCancleButton())); connect(ui->recoverButton,SIGNAL(clicked()),this,SLOT(clickBackButton())); } comDialog::~comDialog() { delete ui; } void comDialog::getCom() { ui->portcomboBox->clear(); for(int portCount = 1;portCount< 17;i++) //听说COM口最多16 { QString strCom = "COM"; strCom += QString::number(portCount,10); HANDLE Win_Handle =CreateFileA(strCom.toAscii(),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if(Win_Handle != INVALID_HANDLE_VALUE) { ui->portcomboBox->addItem(strCom); CloseHandle(Win_Handle); } } } //取消 void comDialog::clickCancleButton() { this->close(); } //确定 void comDialog::clickCommitButton() { comPort = ui->portcomboBox->currentText(); comBaud = ui->baudcomboBox->currentIndex(); comStopBit = ui->stopBitcomboBox->currentIndex(); comDataBit = ui->dataBitcomboBox->currentIndex(); comPariy = ui->paritycomboBox->currentIndex(); comFlow = ui->flowCtrlcomboBox->currentIndex(); } //恢复默认 void comDialog::clickBackButton() { ui->baudcomboBox->setCurrentIndex(7); ui->stopBitcomboBox->setCurrentIndex(0); ui->dataBitcomboBox->setCurrentIndex(3); ui->paritycomboBox->setCurrentIndex(0); ui->flowCtrlcomboBox->setCurrentIndex(0); } //效果图如下: /////////////////////////////////////////////////////////////////////
相关文章推荐
- linux系统管理客户端2--串口实现测试代码编写
- 我不要紧的编码组两人,至少两年的dotnet网咯服务开发经验,熟悉数据库orm, 系统管理人员:熟悉各linux发行版的系统管理和安全管理,linux常用数据库的配置与运维等,有代码托管服务管理经验优
- Linux系统下tomcat自动拉取代码打包发布的配置部署和脚本编写(转朋友)
- Linux系统管理实践(6):系统登录配置
- 在嵌入式Linux 系统中实现基于Web 的配置管理
- Linux系统管理实践(10):PPPoE上网配置
- java编写学生成绩管理系统代码
- Linux系统管理命令代码解析
- Debian Linux 系统配置与管理 第8章 读书笔记
- Debian Linux 系统配置与管理 第8章 读书笔记
- 学生信息管理系统(在LINUX下用GCC编译需要更改conio.h为curses.h并修改相关代码)
- 管理类应用系统参数配置管理统一解决方法(含代码参考)
- 【Linux_Fedora_系统管理系列】_1_用户登录和系统初始配置
- Linux_系统管理_网络配置_命令行配置网络
- Linux系统文件目录配置与管理
- 管理类应用系统参数配置管理统一解决方法(含代码参考)
- Linux系统管理实践(9):DHCP服务器配置
- 【Linux系统和服务管理】MySQL服务器安装与配置(一)
- linux带宽管理系统 tc 配置(QOS)
- 配置实现通过串口(com 口、RS232 接口)终端控制 Linux 系统