📄 mainframe.cpp
字号:
#include <string.h>#include <qpushbutton.h>#include "mainframe.h"QSerialSt st = { "/dev/ttyAM1", 9600, 8, 1, 'N'};MainFrame::MainFrame(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name ,f){ int ret; label = new QLabel(this); label->setMinimumSize(100,100); pushButton = new QPushButton("Push", this); pushButton->setMinimumSize(20,20); pushButton->move(100,100); serial = new QSerial(); ret = serial->init( &st ); if(-1 != ret) serial->setNotifier(); connect((QObject*)serial, SIGNAL(readyRead(char*, int)), this, SLOT(readSerial(char*, int))); connect(pushButton, SIGNAL(clicked()), this, SLOT(writeServer()));}MainFrame::~MainFrame(){}void MainFrame::readSerial( char* data, int len){ len = 0; QString str(data); label->setText(str);}void MainFrame::writeServer(){ char *ptr = "welcome to Beijing\n"; serial->writeBlock(ptr, strlen(ptr));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -