Results 1 to 3 of 3

Thread: Multiple setAxisScaleDraw classes

  1. #1
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Multiple setAxisScaleDraw classes

    I am using the setAxisScaleDraw class to print the X Axis date in text. However, I would like to change the value of this text based on the current scale of the plot. If the curve data contains less than a few days worth of data, then I would want to use the
    virtual QwtText label( double value ) const
    {
    QDateTime ThisDate;
    ThisDate = QDateTime::fromTime_t(value);
    return ThisDate.toString("MMM d yy h:m");
    }
    Else, if the curve data contains more than a few days worth of data I would use
    virtual QwtText label( double value ) const
    {
    QDateTime ThisDate;
    ThisDate = QDateTime::fromTime_t(value);
    return ThisDate.toString("MMM d yy");
    }

    Whats the best way to accomplish this.
    Do I add a different QwtScaleDraw that would return the correct version?

    But I am also using a zoomer which means that I may want to automatically switch when I zoom in. I know I am missing something in the docs, but I can't figure it out.

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

    Default Re: Multiple setAxisScaleDraw classes

    Qt Code:
    1. virtual QwtText label( double value ) const
    2. {
    3. QDateTime ThisDate = QDateTime::fromTime_t(value);
    4. if ( scaleDiv().range() < ... )
    5. return ThisDate.toString("MMM d yy h:m");
    6. else
    7. return ThisDate.toString("MMM d yy");
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Uwe

  3. #3
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Multiple setAxisScaleDraw classes [solved]

    Worked perfectly. Thanks!

Similar Threads

  1. Emit one signal from multiple classes
    By Ishmael in forum Qt Programming
    Replies: 4
    Last Post: 28th June 2010, 23:57
  2. How do you run multiple test classes?
    By jeffadams78 in forum Qt Programming
    Replies: 3
    Last Post: 2nd April 2009, 18:39
  3. Multiple Classes setText Update
    By Msnforum in forum Qt Programming
    Replies: 5
    Last Post: 30th January 2009, 15:40
  4. custom axis (setAxisScaleDraw) questions
    By MrGarbage in forum Qwt
    Replies: 7
    Last Post: 11th January 2008, 10:08

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.