转换

来源:互联网 发布:杨澜访谈录 人工智能 编辑:程序博客网 时间:2024/04/29 23:56

太及时了


这里主要涉及到的知识点为Qt的数据类型转为halcon的数据类型。 
GBK.h文件为外部添加头文件,是实现中文转换的文件 
需要将GBK.h文件放在工程目录下,并添加以下代码

#include "GBK.h"#include "halconcpp.h"#include "String.h"using namespace HalconCpp;
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4
int test3::OnBtnReadLocalImage(bool checked){    QString QfilePath = QFileDialog::getOpenFileName(this, GBK::ToUnicode("选择文件"),"d:/","Image(*.png *.jpg *.bmp");    if (0==QfilePath.length())    {        return -1;    }    string str = QfilePath.toLocal8Bit();//从Qstring转换到string    char filePath[100];    strcpy(filePath, str.c_str());//从string转换到char    ReadImage(&ho_Image, filePath);    HTuple ho_Width, ho_Height;    GetImageSize(ho_Image, &ho_Width, &ho_Height);    SetPart(hv_WindowHandle, 0,0,ho_Height, ho_Width);    DispObj(ho_Image,hv_WindowHandle);    return 0;}

原创粉丝点击