Results 1 to 13 of 13

Thread: Time/Date Axis

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time/Date Axis

    i want to have a timescale with millisecond accuracy, but i don't really know how to do that.
    All examples only have second accuracy and always use QDateTime::fromTime_t(int v) or something else.

    Has somebody experiences with that and can give me a tip how to solve that problem?

    thx

  2. #2
    Join Date
    May 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Time/Date Axis

    Hej drizzt.
    My idea would be to create a similar type to time_t where you count milliseconds from some start date.
    The easiest thing would be to use QDateTime::toTime_t of your start date and multiply it to get your milliseconds and add as many milliseconds as needed for the datapoint
    Then you could call

    QDateTime t = QDateTime::addMSecs((qint64)v);
    return t.toString("yyyy-MM-dd HH:mm:ss:zzz");

    in the label function from dinojerm.

    Just take care of the really big number which is lager than an interger, so use qint64.
    I have NOT tested this, it ist just a suggestion.

  3. #3
    Join Date
    Aug 2009
    Location
    The Netherlands
    Posts
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Time/Date Axis

    Hi Phil Winder,
    is it possible to get the datetime.zip? looks like the above link does not contain all the files...after i download, i could not unzip it...

    Thanks in advance

  4. #4
    Join Date
    Nov 2010
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Default Re: Time/Date Axis

    I'm very interested in something similar to this. Basically I need only dates as X axis. Do you thing this snippet is correct?

    QwtPlot *plt = ui->qwtPlot;
    plt->setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw("dd/M/yy"));
    QDate date = getDateFromSomewhere();
    QDateTime tm(date);
    xData.append(tm.toTime_t());
    yData.append(someData());

  5. #5
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    18
    Thanked 68 Times in 66 Posts

    Default Re: Time/Date Axis

    Quote Originally Posted by Patrik View Post
    I'm very interested in something similar to this. Basically I need only dates as X axis. Do you thing this snippet is correct?
    why don't you try it by yourself?

  6. #6
    Join Date
    May 2010
    Posts
    86
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    17
    Thanked 2 Times in 2 Posts

    Default Re: Time/Date Axis

    Hi Philminder, I tried your example under 6.00-rc5, and it fails at:

    ..\datetime\mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
    ..\datetime\mainwindow.cpp:40: error: no matching function for call to 'QwtPlotCurve::setData(double*, double*, int)'
    ..\libraries\qwt/qwt_plot_seriesitem.h:146: note: candidates are: void QwtPlotSeriesItem<T>::setData(QwtSeriesData<T>*) [with T = QPointF]

    It looks like setData arguments have changed...

  7. #7
    Join Date
    Jul 2010
    Posts
    37
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    13

    Default Re: Time/Date Axis

    please download latest Qwt (6.0) and recompile: it should works.

  8. #8
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    62
    Thanked 4 Times in 4 Posts

    Default Re: Time/Date Axis

    corrado1972 -
    I downloaded datetime.zip and curve->setData(&xData[0], &yData[0], xData.size()); (mainwindow.cpp line40) does not compile with Qwt 6.0.0.

    setData should be replaced with setRawSamples
    Last edited by TorAn; 30th April 2011 at 16:09.

  9. #9
    Join Date
    Jul 2010
    Posts
    37
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    13

    Default Re: Time/Date Axis

    TorAn excuse me but I understood that the problem was referred to the examples included in Qwt release.
    My advice is to discard the datetime.zip and look in the examples, friedberg and cpuplot: there is all the necessary to get datetime axis.
    bye

Similar Threads

  1. Relocating axis labels
    By malcom2073 in forum Qwt
    Replies: 0
    Last Post: 9th May 2008, 13:01
  2. Set axis title on the right side
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 14th March 2008, 07:26
  3. Qwt and custom axis
    By jiveaxe in forum Qwt
    Replies: 3
    Last Post: 14th November 2007, 15:50
  4. Qwt - extra axis
    By steg90 in forum Qwt
    Replies: 2
    Last Post: 10th July 2007, 14:41

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
  •  
Qt is a trademark of The Qt Company.