Hello,
It was a misunderstood.
Let me explain better.
The epoc I have now it was just a test. The real situation is:
The user is gonna write a date in a textfield: Sun Mar 04 21:55:29 2001.
After the user writes he's gonna press a button.
When this button is pressed the software gets the string (textfield): Sun Mar 04 21:55:29 2001, and converts this string to an epoc.
The function that gets the user click is:
void MainWindow::zoomInClicked()
{
if (yMinField->text()=="" || yMaxField->text()=="" || xMinField->text()=="" || xMaxField->text()=="" )
{
QMessageBox::critical(this,
"",
"Values to XY-min and XY-max must be setted.");
}
else
{
time_t xMinEpoch = dt.toTime_t();
dt
= QDateTime::fromString(xMaxField
->text
(),
"ddd MMM dd hh:mm:ss yyyy");
time_t xMaxEpoch = dt.toTime_t();
plot
[graphAreaSelection
->currentIndex
()]->setAxisScale
(QwtPlot::xBottom,
(xMinEpoch
).
toDouble(),
(xMaxEpoch
->text
()).
toDouble());
plot[graphAreaSelection->currentIndex()]->setAxisScale(channelSelection->currentIndex(), (yMinField->text()).toDouble() , (yMaxField->text()).toDouble() );
plot[graphAreaSelection->currentIndex()]->replot();
}
}
void MainWindow::zoomInClicked()
{
if (yMinField->text()=="" || yMaxField->text()=="" || xMinField->text()=="" || xMaxField->text()=="" )
{
QMessageBox::critical(this, "", "Values to XY-min and XY-max must be setted.");
}
else
{
QDateTime dt = QDateTime::fromString(xMinField->text(),"ddd MMM dd hh:mm:ss yyyy");
time_t xMinEpoch = dt.toTime_t();
dt = QDateTime::fromString(xMaxField->text(),"ddd MMM dd hh:mm:ss yyyy");
time_t xMaxEpoch = dt.toTime_t();
plot[graphAreaSelection->currentIndex()]->setAxisScale(QwtPlot::xBottom, (xMinEpoch).toDouble(), (xMaxEpoch->text()).toDouble());
plot[graphAreaSelection->currentIndex()]->setAxisScale(channelSelection->currentIndex(), (yMinField->text()).toDouble() , (yMaxField->text()).toDouble() );
plot[graphAreaSelection->currentIndex()]->replot();
}
}
To copy to clipboard, switch view to plain text mode
This is the code, the plot part I'm not sure if it's working because of the convertion to double, and I was not using, I put a break point before to check the time_t value. The problem is: the dt is always 0,0,0,-1, then the time_t is wrong.
Thanks for the reply
Any ideas?
Bookmarks