【发布时间】:2017-05-21 04:28:00
【问题描述】:
我正在使用 QTextStream 将数据写入文件。它组织得很好(几乎完美),例如:
i t y yy
0 0.0166667 -0.649999 67.6666
1 0.0333333 0.477777 -43.4444
2 0.05 -0.246295 30.6295
3 0.0666666 0.264197 -18.753
4 0.0833333 -0.0483533 14.1687
5 0.1 0.187791 -7.7791
6 0.116667 0.0581394 6.85273
7 0.133333 0.172351 -2.90181
8 0.15 0.123988 3.60121
9 0.166667 0.184008 -0.734136
以上内容出自
stream << qSetFieldWidth(5) << i
<< qSetFieldWidth(12) << t
<< qSetFieldWidth(12) << y
<< qSetFieldWidth(12) << yy
<< endl;
但我希望列按点(小数点分隔符)对齐,例如:
0 0.0166667 -0.649999 67.6666
1 0.0333333 0.477777 -43.4444
2 0.05 -0.246295 30.6295
3 0.0666666 0.264197 -18.753
4 0.0833333 -0.0483533 14.1687
5 0.1 0.187791 -7.7791
6 0.116667 0.0581394 6.85273
7 0.133333 0.172351 -2.90181
8 0.15 0.123988 3.60121
9 0.166667 0.184008 -0.734136
我该怎么做?
【问题讨论】: