Results 1 to 13 of 13

Thread: Time in x - axis

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 3 Times in 3 Posts

    Default Re: Time in x - axis

    Hi Faramia,

    the main idea is that you have the normal x-axis in the plot, I mean
    x from 1 to ...
    and you have to convert to hours, in the label method
    for example, when x = 1 then hour = 7:00

    virtual QwtText label(double v) const v is the x-value in the plot
    {
    // check if v is an integer value

    // if yes do this
    qDebug() << "basetime to string" << baseTime.toString() << "v:" << v << "i:" << i;
    qDebug() << baseTime.addSecs(3600*v).toString();
    return baseTime.addSecs(3600*v).toString();
    // if not
    return EMPTY_STRING;
    }

    then, you have to change your code to

    setAxisScale(xBottom, 1,1+numOfHours, 1); // numOfHours = number of hours you want to show
    QTime myTime(7,00);
    setAxisScaleDraw(QwtPlot::xBottom,
    new QwtScaleDrawTime(myTime));

  2. The following user says thank you to desantossierra for this useful post:

    Faramia (3rd February 2012)

Similar Threads

  1. Replies: 1
    Last Post: 2nd August 2011, 18:01
  2. Replies: 9
    Last Post: 3rd May 2011, 21:21
  3. Time/Date Axis
    By sigger in forum Qwt
    Replies: 12
    Last Post: 1st May 2011, 09:55
  4. Replies: 2
    Last Post: 8th February 2011, 14:53
  5. Replies: 0
    Last Post: 9th August 2010, 10:46

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.