#ifndef WIDGET_H
#define WIDGET_H
#include "posix_qextserialport.h"
#include<QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
Posix_QextSerialPort *myCom;
private slots:
// void on_ReceivePushButton_clicked();
void on_SendPushButton_clicked();
};
#endif // WIDGET_H
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
//定义一个结构体,用来存放串口各个参数
struct PortSettings myComSetting = {BAUD115200,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,50};
//定义串口对象,并传递参数,在构造函数里对其进行初始化
myCom = new Posix_QextSerialPort("com1",myComSetting,QextSerialBase::EventDriven);
//以可读写方式打开串口
myCom->open(QIODevice::ReadWrite);
//信号和槽函数关联,写数据到串口缓冲区
connect(myCom,SIGNAL(readyWrite()),this,SLOT(on_SendPushButton_clicked()));
connect(ui->SendPushButton, SIGNAL(clicked()), this, SLOT(Widget()));
// connect(ui->ReceivePushButton, SIGNAL(clicked()), this, SLOT(Widget()));
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_SendPushButton_clicked()
{
myCom->write(ui->SendtextEdit->toPlainText().toAscii());
}
我想用一个按钮按一下 就可以把textedit中的数据发送到串口缓冲区中去 我用qt in path debug下运行成功出现了界面,为什么在qt in path release下编译就报错我用的是4.7.3
------解决方案--------------------
错误内容呢?