> 文章列表 > Qt中使用

Qt中使用

Qt中使用

LIB库路径,include 头文件,运行的时候记得吧dll库带上,这基本就完成了。

准备工作:

Qt可以是傻瓜式的安装就行,GE的驱动里面有exe,直接点击安装即可,完了记得到安装路径把“.h”“.liib”和“.dll”文件拷贝出来

接下来在Qt里面做好基本工作

主要就是修改pro文件,在pro中添加头文件路径和lib库路径。

INCLUDEPATH += C:\\Users\\WorkStation\\Desktop\\GE5565\\GECore\\Inc

LIBS += -LC:\\Users\\WorkStation\\Desktop\\GE5565\\GECore\\Lib -lrfm2gdll_stdc_32

在调用文件中include头文件

#include "rfm2g_windows.h"

#include "rfm2g_api.h"

剩下的就是基本的open read write close 了。

//open

void MainWindow::onpushbuttonopen()

{

RFM2G_STATUS result;

QString strpath = "\\\\\\\\.\\\\rfm2g";

strpath += ui->lineEdit_num->text();

QByteArray ba = strpath.toLatin1();

char *device = ba.data();

result = RFM2gOpen( device, &m_Handle);

if(result != RFM2G_SUCCESS)

{

qDebug() << device;

return;

}

m_timer->start(100);

}

//read

void MainWindow::onTimerOut()

{

RFM2G_STATUS result;

char buff[BUFFERSIZE];

result = RFM2gRead(m_Handle,OFFSET,buff,BUFFERSIZE);

QString strtext(buff);

if(strtext != m_strLast)

{

ui->textEdit_read->setText(strtext);

m_strLast = strtext;

}

}

//close

MainWindow::~MainWindow()

{

delete ui;

if(m_Handle)

{

RFM2gClose(&m_Handle);

}

}

最后就是DOME的连接测试了