Qt sscanf equivalent
Qt sscanf equivalent
说我有这个:
QString mystring = "67 49 213 59";
int a, b, c, d;
是否有SSCANF的QT替代方案,以便我可以将数字读取到int
变量中?
QTextStream
提供了标准库流的等效。不要忘记,在字符串之前,应在之前销毁文本流。
QString mystring = "67 49 213 59";
QTextStream myteststream(&mystring);
int a = 0, b = 0, c = 0, d = 0;
myteststream >> a >> b >> c >> d;
int a, b, c, d;
QString s("67 49 213 59");
QTextStream(&s) >> a >> b >> c >> d;
QString str("67 49 213 59");
QStringList list = str.split(" ");
int a[list.count];
for (int i = 0; i < list.count; i++)
a[i] = list[i].toInt();
您总是可以做
QByteArray oString = mystring.toAscii();
const char *pszString = oString.constData();
然后使用sscanf()正常。
相关文章:
- 用C++中的sscanf赋值
- 为什么 sscanf 无法从一个字符串中读取uint64_t和字符?
- 具有结构成员char数组的sscanf
- 在 Arduino 上使用 sscanf 会导致与 const char * 不匹配,并且返回值始终相同,尽管输入值不同
- C++ equivalent to Java Map getOrDefault?
- Equivalent of OpenCv c++ api Vec2f,norm, acos in emgucv csha
- Win32 equivalent of getgid
- vfprintf_unlocked() equivalent?
- sscanf() 有两个字符串参数
- SSCANF 进入 uint8 阵列失败
- What is the std::chrono::time_point equivalent of std::numer
- Arduino使用sscanf读取浮点数
- AVX equivalent for _mm_movelh_ps
- python equivalent of std::chrono::steady_clock::now();
- C++ Equivalent of Java Map<String, Object>
- 使用 sscanf 设置结构引用的值
- TrackPopupMenu equivalent in OS X
- Qt sscanf equivalent
- sscanf equivalent for std::string
- C++ equivalent of sscanf?