?? mainfrm.ui.h~
字號:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include "serial.h"#include <iostream.h>#include <qtimer.h>#include <qmessagebox.h>Serial comm;QTimer *recTimer;using namespace std;void mainFrm::OpenPort(){ int baud,databit; if (!comm.readyTTY(comPort->currentItem())) { QMessageBox::information(this,"serial commucation","Can't Open Serial Port!"); return; } comm.lockTTY(); baud = atoi(comBaud->currentText()); comm.setTTYSpeed(baud); databit = atoi(comData->currentText()); comm.setTTYParity(databit,'N',1); recTimer = new QTimer( this,"timer" ); connect( recTimer, SIGNAL(timeout()), this, SLOT(showData())); recTimer->start(10,FALSE); //if TRUE, timer execute one closeBtn->setEnabled(true); openBtn->setEnabled(false);}void mainFrm::closeComm(){ comm.cleanTTY(); openBtn->setEnabled(true); closeBtn->setEnabled(false); delete recTimer;}void mainFrm::sendData(){ const char *str = txt->text(); char buf[] = "\n\r"; comm.sendnTTY((char*)str,strlen(str)); comm.sendnTTY(buf,2);}void mainFrm::showData(){ char buf[100]; memset(buf,'\0',sizeof(buf)); cout << "yangsen" << endl; if (comm.recvnTTY(buf,sizeof(buf))>0) show_content->setText(show_content->text()+QString(buf));}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -