1、HTuple 转 QString
QString str;
HTuple h1 = "a1";
str = QString::fromUtf8(h1.S().Text());
HTuple h2 = 10;
str = QString::number(h2.I());
HTuple h3 = 10.0;
str = QString::number(h3.D());
2、QString转HTuple
2.1 qt读取本地图片,里面包含QString转HTuple
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setFileMode(QFileDialog::ExistingFile);
QString filePath = dlg.getOpenFileName();
std::string str1 = filePath.toStdString();
const char *str = str1.c_str();
HTuple h_FilePath(str);
if (!filePath.isEmpty())
{
ReadImage(&ho_Image, h_FilePath);
}
2.2 一行代码转换
QString str1 = "A1";
HTuple str2;
str2 = HTuple(str1.toStdString().c_str());
3.基本类型转换
HTuple h1 = 10;
int value1 = h1.I();
HTuple h2 = 10.0;
double value2 =h2.D();
C++的int和double类型可以直接赋值给HTuple。