Results 1 to 4 of 4

Thread: Show System Time Stamp ??

  1. #1
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Show System Time Stamp ??

    Hi friends i am trying to print the system time as the Bottom X Axis of a QwtPlot Widget. But i am having problem doing it i get so many errors when i compile is there any easier way to do it.I tried the DataPlot example in this program but i have so many errors. Here is the code

    Qt Code:
    1. #include "qwt_plot.h"
    2. #include "qwt_scale_widget.h"
    3. #include <QTimer>
    4. #include <stdlib.h>
    5. #include <qwt_plot_curve.h>
    6. #include <qwt_plot_grid.h>
    7. #include <QTime>
    8.  
    9. PlottingGraph::PlottingGraph(QWidget *parent)
    10. : QDialog(parent)
    11. , m_curve(0)
    12. , m_time(0)
    13.  
    14. {
    15. setupUi(this);
    16. connect(drawButton, SIGNAL(clicked()), this, SLOT(draw()));
    17.  
    18. QTimer *timer = new QTimer(this);
    19. connect(timer, SIGNAL(timeout()), this, SLOT(draw()));
    20. timer->start(300);
    21.  
    22. for (int i = 0; i < 100; i++)
    23. {
    24. m_x[i] = i;
    25. m_y[i] = 0.0;
    26. }
    27.  
    28. myPlot->setTitle("Temperature Channel");
    29. myPlot->setAxisTitle(QwtPlot::xBottom, "System Uptime [h:m:s]");
    30. myPlot->setAxisScaleDraw(QwtPlot::xBottom,
    31. new TimeScaleDraw(cpuStat.upTime()));
    32. myPlot->setAxisScale(QwtPlot::xBottom, 0, HISTORY);
    33. myPlot->setAxisTitle(QwtPlot::yLeft, "Values");
    34. myPlot->setAxisScale(QwtPlot::yLeft, -10000, 10000);
    35. myPlot->setAutoReplot(true);
    36. }
    37. void PlottingGraph::on_drawButton_clicked()
    38. {
    39. }
    40. void PlottingGraph::draw()
    41. {
    42. m_time++;
    43. memmove(m_y, &m_y[1], 99 * sizeof(double));
    44. m_y[99] = 1000 * sin((double)m_time / 360 * 3.1415 * 100) + rand() % 4000 - 2000;
    45. for (int i = 0; i < 100; i++)
    46.  
    47. m_x[i]++;
    48.  
    49. if (!m_curve)
    50. {
    51. m_curve = new QwtPlotCurve();
    52. m_curve->setPen(QPen(Qt::red));
    53. m_curve->setData(m_x, m_y, 100);
    54. QwtPlotGrid *gridy = new QwtPlotGrid();
    55. gridy->attach(myPlot);
    56. m_curve->attach(myPlot);
    57. }
    58. m_curve->setData(m_x, m_y, 100);
    59. myPlot->setAxisScale(QwtPlot::xBottom, timeData[HISTORY - 1], timeData[0]); //m_time, m_time + 100); // auto replots
    60. QTime time = QTime::currentTime();
    61. myPlot->setAxisScale(QwtPlot::xBottom, time.("h:m:s"));
    62. }
    63.  
    64.  
    65. void PlottingGraph::timerEvent(QTimerEvent *)
    66. {
    67. for ( int i = dataCount; i > 0; i-- )
    68. {
    69. for ( int c = 0; c < NCpuData; c++ )
    70. {
    71. if ( i < HISTORY )
    72. data[c].data[i] = data[c].data[i-1];
    73. }
    74. }
    75.  
    76. cpuStat.statistic(data[User].data[0], data[System].data[0]);
    77.  
    78. data[Total].data[0] = data[User].data[0] +
    79. data[System].data[0];
    80. data[Idle].data[0] = 100.0 - data[Total].data[0];
    81.  
    82. if ( dataCount < HISTORY )
    83. dataCount++;
    84.  
    85. for ( int j = 0; j < HISTORY; j++ )
    86. timeData[j]++;
    87.  
    88. setAxisScale(QwtPlot::xBottom,
    89. timeData[HISTORY - 1], timeData[0]);
    90.  
    91. for ( int c = 0; c < NCpuData; c++ )
    92. {
    93. data[c].curve->setRawData(
    94. timeData, data[c].data, dataCount);
    95. }
    96.  
    97. replot();
    98. }
    To copy to clipboard, switch view to plain text mode 

    Thank You

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Show System Time Stamp ??

    You could start by showing us the errors.

  3. #3
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Show System Time Stamp ??

    Hi the reason i din put the error's is because i think there is some thing wrong with the code. I
    am not sure if the time stamp code is fine. Can u pls tell me where i am going wrong.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Show System Time Stamp ??

    How do you expect us to analyze your code if we don't know what to look for? You didn't even tell us the nature of the problem. You just said you want a timestamp and that it doesn't compile. Could you please paste the first error you get?

Similar Threads

  1. file time stamp preservation
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 8th April 2008, 00:13
  2. Show progress of a time consuming operation
    By rainman110 in forum Newbie
    Replies: 7
    Last Post: 10th February 2008, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.