desantossierra, I get the value of X and Y axes from the database:
query.exec("SELECT tm, val FROM currstamp where id = 1136");
if (query.next())
{
osX = query.value(0).toUInt();
osY = query.value(1).toDouble();
}
vectX.append(osX);
vectY.append(osY);
curv1->setSamples(vectX,vectY);
query.exec("SELECT tm, val FROM currstamp where id = 1136");
if (query.next())
{
osX = query.value(0).toUInt();
osY = query.value(1).toDouble();
}
vectX.append(osX);
vectY.append(osY);
curv1->setSamples(vectX,vectY);
To copy to clipboard, switch view to plain text mode
Data for the X axis, I get in the Unix time format ( 1328676218, 1328676230,etc...).
And I need to value time, obtained from the database, on the plot looked like this: 08/02/2012 12:32:05
Problem was solved. Added
{
public:
TimeScaleDraw(/*const QTime &base*/)/* : baseTime(base)*/
{
setLabelRotation(0);
setLabelAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setSpacing(20);
}
virtual QwtText label
(double v
) const {
time = time.fromTime_t(v);
return time.toString("yyyy.MM.dd.\nhh:mm:ss");
}
};
class TimeScaleDraw: public QwtScaleDraw
{
public:
TimeScaleDraw(/*const QTime &base*/)/* : baseTime(base)*/
{
setTickLength(QwtScaleDiv::MajorTick, 6);
setTickLength(QwtScaleDiv::MinorTick, 0);
setTickLength(QwtScaleDiv::MediumTick, 0);
setLabelRotation(0);
setLabelAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setSpacing(20);
}
virtual QwtText label(double v) const
{
QDateTime time;
time = time.fromTime_t(v);
return time.toString("yyyy.MM.dd.\nhh:mm:ss");
}
};
To copy to clipboard, switch view to plain text mode
if (query.next())
{
osX = query.value(0).toUInt();
qDebug() << osX;
osY = query.value(1).toDouble();
}
qDebug() << time1.fromTime_t(osX).toTime_t();
vectX.append(time1.fromTime_t(osX).toTime_t());
vectY.append(osY);
curv1->setSamples(vectX,vectY);
if (query.next())
{
osX = query.value(0).toUInt();
qDebug() << osX;
osY = query.value(1).toDouble();
}
qDebug() << time1.fromTime_t(osX).toTime_t();
vectX.append(time1.fromTime_t(osX).toTime_t());
vectY.append(osY);
curv1->setSamples(vectX,vectY);
To copy to clipboard, switch view to plain text mode
Bookmarks