C ++ / QT Qstring中的类型转换 [英] type conversion in C++/QT Qstring
本文介绍了C ++ / QT Qstring中的类型转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨程序员!
我从DLL文件中获取数据时有一个问题。
Hi programmers!
I have one issue while i am fetching data from DLL file.
if (PCANReadS == PCAN_ERROR_OK)
{
Dataid = QString::number(msg.ID, 16);
nt temp =* (int*)msg.DATA;
MsgType = msg.MSGTYPE;
//MsgDLC = msg.LEN;
MsgDLC = QString::number(msg.LEN, 10);
Datain = QString::number(temp, 16);
TStmpMilliCurrent = QString::number(timestamp.millis, 10);
TStmpMicroCurrent = QString::number(timestamp.micros, 10);
}
我想要做的是获得当前时间戳和之前时间戳之间的差异。
当我减去它时会给我错误,因为两者都是Qstring。
如何在两个时间戳之间得到这个差异?
What i want to do is getting the difference between current time stamp and previous.
When i subtract it gives me error because both are in Qstring.
How i can get this difference between two time stamps?
推荐答案
一个关于如何根据可用代码存储时间戳的不完整示例:
An incomplete example on how to store a timestamp based on the available code:
int prevTime = 0;
void someFunction()
{
if (PCANReadS == PCAN_ERROR_OK)
{
int diffTime = 0;
// If not first frame
if (prevTime)
difftime = timestamp.millis - prevTime;
prevTime = timestamp.millis;
}
}
最好使用与 timestamp
相同的类型全局变量。但我不知道这种类型。
It would be better to use the same type as timestamp
for the global variable. But I did not know the type.
这篇关于C ++ / QT Qstring中的类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文