C++ is displaying a number 3232235975
on QLabel
as 3.23223e+9
, while on QCustomPlot
axis as 3.23223*10^9
. I am not involving stream such as std::cout
, that is why std::setprecision
doesn't work for my case.
Am actually working with QCustomPlot
to plot graph with 12digit numbers on the axis. Is this C++ issue or is it QCustomPlot
mechanism issue? How can I display all the digits of the number?
Thanks
EDIT: After receiving hint of setNumberPrecision()
from @saeed, now the coordination is still showing in 2.88798e+9 format. Now that the axis is already showing 4000000000, I want the coordination QLabel
(shown in the image I attached) also display 2887984335.
I am getting the coordination and setting it to a QLabel like this.
double x2 = ui->widget_graph2->xAxis->pixelToCoord(_mouseEvent->pos().x());
double y2 = ui->widget_graph2->yAxis-pixelToCoord(_mouseEvent->pos().y());
ui->label_xcoord_2->setNum(x2);
ui->label_ycoord_2->setNum(y2);
And I'm setting the plot data using setData()
like this
QVector<double> x2(i), y2(i);
for(int o = 0; o <= i; o++){
double dSec = arrayIPxTime[o][0] - startSecond;
double dMin = dSec/60;
double ipv4addr = arrayIPxTime[o][1];
x2[o] = dMin;
y2[o] = ipv4addr;
}
ui->widget_graph2->addGraph(0);
ui->widget_graph2->graph(0)->setData(x2, y2);
ui->widget_graph2->installEventFilter(this);
If you want to create following just as
qCustomPlot
sample set axis properties like codes bellow.setNumberPrecision sets number of float digits if you set it to zero may show all digits in plot axis.
setNumberFormat("g") also may show all digits too , anyway qCustomplot try to show values alongside axis as beauty can be.
Here is a preview.
I'm guessing you want std::setprecision.
To display coordinates in your wanted format
Use
void setText(const QString &)
method for QLabel and passAs parameter with your wanted format and precision: