Project

General

Profile

Actions

Bug #1892

closed

TableView render double incorrect

Added by Ariel Kruger almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
05/04/2013
Due date:
% Done:

0%

Estimated time:

Description

I have a WTableView that has some collumns with the value 50.54 from a QueryModel,

but the table shows me 50.53999999999

Actions #1

Updated by Stefan Ruppert almost 11 years ago

Ariel Kruger wrote:

I have a WTableView that has some collumns with the value 50.54 from a QueryModel,

but the table shows me 50.53999999999

Hi,

I had a similar problem. AFAIK Wt uses sprintf("g") to format a double value in its string stream which can lead in such output. Also boost::lexical_caststd::string(double) is used. I uses an explicit sprintf(".2f") which solved my formatting issue.

However maybe double to string conversion should be unified and made more flexible by providing a setter for specifying the used formatter string for sprintf()!?

Regards,

Stefan

Actions #2

Updated by Koen Deforche almost 11 years ago

  • Status changed from New to Closed
  • Assignee set to Koen Deforche
  • Target version set to 3.3.0

Hey,

What you should do is configure the TextFormat in the item delegate that is used to render the double data.

Another solution is to provide DisplayRole data as strings, but keep the double as EditRole data; this is really the spirit of the different roles for the models. You can do that by specializing QueryModel (in this case).

Regards,

koen

Actions

Also available in: Atom PDF