开发者

Qt - Problems while serializing "double"

开发者 https://www.devze.com 2023-01-08 09:50 出处:网络
I serialize \"double\" data type and get an error though QDataStream & operator<< ( double f )

I serialize "double" data type and get an error though

 QDataStream & operator<< ( double f )

operator is defined. Here is the error message:

 error: conversion from 'double' to 'const QChar' is ambiguous

Did you meat this situation or understand why 开发者_运维知识库it can be like this?


It sounds like it can't see the operator for double, so it's trying to implicitly create a QChar from the double to send to the stream, but QChar has multiple constructors that could possibly match.

Make sure that your header includes are all correct.

Can you show us the code where you're trying to serialize the double?


You might find it useful to write any double-literals (if you're using any) with the decimal portion as well, i.e.

ds << 0.0;

Rather than

ds << 0;

It probably won't solve your problem, but it'll cut down any ambiguity!

0

精彩评论

暂无评论...
验证码 换一张
取 消