Narek
Narek

Reputation: 39881

Qt - Problems while serializing "double"

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?

Upvotes: 6

Views: 1311

Answers (2)

leegent
leegent

Reputation: 964

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!

Upvotes: -1

Mark B
Mark B

Reputation: 96233

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?

Upvotes: 9

Related Questions