美文网首页
Qt 常用类型转换

Qt 常用类型转换

作者: 爱写诗的程序员zxp | 来源:发表于2020-05-15 08:43 被阅读0次

QString 转 BSTR

1、BSTR s = SysAllocString(L"s1");
2、QString s2 = "test string";
      BSTR s = SysAllocString((OLECHAR*)s2.unicode());

BSTR 转 QString

BSTR bstr;
QString s = QString::fromUtf16(reinterpret_cast<ushort*>(bstr));

LPCWSTR 转 QString

LPCWSTR lpszStr;
QString s1 = QString::fromStdWString(lpszStr);

QString 转 LPCWSTR

QString s1 = "test string";
std::wstring wlpstr = s1.toStdWString();
LPCWSTR lpcwStr = wlpstr.c_str();

QString 地址串 转 16进制值

QString src = "0xba451641";
QString s = src .mid(src .indexOf("x") + 1);
LONGLONG ll = s.toUtf8().toUInt(Q_NULLPTR, 16);

LPCTSTR转QString

LPCTSTR lpctStr;
QString s = QString::fromUtf16(reinterpret_cast<ushort*>((LPTSTR)lpctStr));

相关文章

  • Qt 常用类型转换

    QString 转 BSTR BSTR 转 QString LPCWSTR 转 QString QString 转...

  • 10分钟快速上手angular cdk

    coercion 常用类型转换工具 @angular/cdk/coercion 常用类型转换工具 layout 响...

  • 类型的强制转换

    数据类型转换:类型名(被转换的数据) 常用数据类型:int float bool str 1.其它的数据类型转换成...

  • Python数据类型转换

    本文主要介绍Python中的常用数据类型转换,更多内容请参考:Python学习指南 常用的数据类型转换

  • 常用类型转换

  • 类型转换,匿名函数,智能指针

    类型转换 C++中有4个类型转换符 static_cast : 常用于基本数据类型的转换、非const转成cons...

  • 4.函数

    数据类型转换 Python内置的常用函数还包括数据类型转换函数,比如int()函数可以把其他数据类型转换为整数: ...

  • 2019-05-06 Python --调用函数

    数据类型转换 Python内置的常用函数还包括数据类型转换函数,比如int()函数可以把其他数据类型转换为整数: ...

  • C/C++ static_cast/dynamic_cast/c

    Qt之数据类型转换原文连接static_cast dynamic_cast const_cast reinterp...

  • js常用math方法

    Math常用方法 js常用数据类型转换 toString():转换成字符串;String():吧unll、unde...

网友评论

      本文标题:Qt 常用类型转换

      本文链接:https://www.haomeiwen.com/subject/flsqohtx.html