首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

qreal怎么转换到QString

2012-09-14 
qreal如何转换到QString错误: 对成员‘toString’的请求出现在‘((QBBall*)this)-QBBall::position.QPointF:

qreal如何转换到QString
错误: 对成员‘toString’的请求出现在‘((QBBall*)this)->QBBall::position.QPointF::y()’中,而后者具有非类类型‘qreal’
 该如何转化呢,想了半天也没找到方法。

[解决办法]
typedef qreal 
Typedef for double on all platforms except for those using CPUs with ARM architectures. On ARM-based platforms, qreal is a typedef for float for performance reasons. 

所以你可以使用
QString QString::number ( double n, char format = 'g', int precision = 6 ) [static] 
This is an overloaded member function, provided for convenience. 
Returns a string equivalent of the number n, formatted according to the specified format and precision. The format can be 'f', 'F', 'e', 'E', 'g' or 'G' (see the arg() function documentation for an explanation of the formats). 
Unlike QLocale::toString(), this function does not honor the user's locale settings. 
See also setNum() and QLocale::toString(). 

热点排行