Results 1 to 10 of 10

Thread: How to plot a simple function with QDateTime X axis and int/double Y axis?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    May 2010
    Posts
    86
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    17
    Thanked 2 Times in 2 Posts

    Default Re: How to plot a simple function with QDateTime X axis and int/double Y axis?

    I solved it, please, find it here for future reference:

    Qt Code:
    1. QwtScaleDiv ChartPlot::scaleDiv()
    2. {
    3. QList<double> ticks[QwtScaleDiv::NTickTypes];
    4.  
    5. QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
    6.  
    7. foreach (double val, xData)
    8. majorTicks += val;
    9.  
    10. if (xData.count()>1)
    11. {
    12. QList<double> &mediumTicks = ticks[QwtScaleDiv::MediumTick];
    13. for (int i = 0; i < xData.count() - 1; i++)
    14. for (int j = 1; j < 6; j++)
    15. mediumTicks += xData[i] + j * (xData[i+1] - xData[i]) / 5;
    16.  
    17. QList<double> &minorTicks = ticks[QwtScaleDiv::MinorTick];
    18. for (int i = 0; i < xData.count()*10 - 1; i++)
    19. for (int j = 1; j < 11; j++)
    20. minorTicks += xData[i] + j * (xData[i+1] - xData[i]) / 10;
    21. }
    22.  
    23. return QwtScaleDiv(xData.first(), xData.last(), ticks);
    24. }
    To copy to clipboard, switch view to plain text mode 

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

    corrado1972 (4th May 2011)

Similar Threads

  1. Replies: 2
    Last Post: 8th February 2011, 14:53
  2. Replies: 0
    Last Post: 9th August 2010, 10:46
  3. Replies: 1
    Last Post: 30th July 2010, 07:23
  4. Virtual axis ?
    By viridis in forum Qwt
    Replies: 2
    Last Post: 1st July 2008, 15:28
  5. Qwt and custom axis
    By jiveaxe in forum Qwt
    Replies: 3
    Last Post: 14th November 2007, 15:50

Tags for this Thread

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.