Results 1 to 3 of 3

Thread: Scale change for seconds / milliseconds

  1. #1
    Join Date
    Jan 2017
    Posts
    2
    Thanks
    1

    Default Scale change for seconds / milliseconds

    Hello All,

    I have just started with the Qt and Qwt.

    The tool I am developing, the X axis is represented by time - seconds and milliseconds and Y axis the values corresponding to the time. Tool also has a combo box which zooms the chart. The entries in combo range from 10 seconds down to 1 millisecond. (10sec, 5sec, 2sec, 1sec, 500msec, 250 msec, 100msec, 50msec, 10msec, 5 msec and 1msec). The requirement is when the user selects the time in seconds in combo box, the X axis should show "seconds" as title and when milliseconds should show "milliseconds". I am able to set the title correctly, as I check the index in combo, to toggle between "seconds" and "milliseconds".

    I am using SetAxisScale method. When user selects "10sec" I set min and max for SetAxisScale diving by 1000 but when user has "10msec" in combo I call SetAxisScale but the charts do not understand whether 10 is sec or msec and is wrong.

    Summary:
    =======

    User selects "10sec", title is "seconds". Ticks should show 10, 20, 30... I call SetAxisScale with data divided by 1000.
    User selects "10msec", title is "milliseconds". Ticks should again show 10, 20, 30...


    How do I set the ticks correctly and the chart data correctly?

    Regards,
    Nijaguna

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scale change for seconds / milliseconds

    Assuming your data is in ms:

    Qt Code:
    1. class YourScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. ....
    5.  
    6. virtual QwtText label( double value ) const override
    7. {
    8. if ( m_mode == Seconds )
    9. value /= 1000.0;
    10.  
    11. return QwtScaleDraw::label( value );
    12. }
    13.  
    14. private:
    15. Mode m_mode;
    16. };
    17.  
    18. plot->setAxisScaleDraw( ..., new YourScaleDraw(...) );
    To copy to clipboard, switch view to plain text mode 
    Uwe

  3. The following user says thank you to Uwe for this useful post:

    Nijaguna (16th January 2017)

  4. #3
    Join Date
    Jan 2017
    Posts
    2
    Thanks
    1

    Default Re: Scale change for seconds / milliseconds

    Thanks a lot ! Able to show the chart correctly.

Similar Threads

  1. Replies: 2
    Last Post: 13th November 2016, 19:30
  2. change 'scale map' of QwtPolarGrid number!
    By sampad1370 in forum Qwt
    Replies: 2
    Last Post: 5th April 2016, 14:38
  3. QwtPlotZoomer not to change the yAxis scale
    By dontgonearthecastle in forum Qwt
    Replies: 6
    Last Post: 14th January 2013, 09:43
  4. Milliseconds from QDateTime
    By scamE in forum Qt Programming
    Replies: 3
    Last Post: 12th September 2010, 20:46
  5. how to change msleep seconds in QThread
    By sdastagirmca in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2010, 13:27

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.