Results 1 to 4 of 4

Thread: setAxisScaleDiv - my scale div is invalid

  1. #1
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default setAxisScaleDiv - my scale div is invalid

    I'm using my own logic to have customized ticks on my scale:

    Qt Code:
    1. // mTimeScaleDiv is a AxisScaleDiv member
    2. mTimeScaleDiv.invalidate();
    3. mTimeScaleDiv.setInterval(0, 40000);
    4. QList<double> majorTicks;
    5. QList<double> minorTicks;
    6.  
    7. for (int i = 0; i < (20 + 1); i++)
    8. {
    9. if (i % 5 == 0)
    10. {
    11. majorTicks.append(i * 2000);
    12. }
    13. else
    14. {
    15. minorTicks.append(i * 2000);
    16. }
    17. }
    18.  
    19. mTimeScaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTicks);
    20. mTimeScaleDiv.setTicks(QwtScaleDiv::MinorTick, minorTicks);
    21.  
    22. // This returns false - why?
    23. bool isValid = mTimeScaleDiv.isValid();
    24.  
    25. setAxisScaleDiv(QwtPlot::xBottom, mTimeScaleDiv);
    To copy to clipboard, switch view to plain text mode 

    Could anyone help me with an explanation why the scale div I'm creating is set to invalid?

  2. #2
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setAxisScaleDiv - my scale div is invalid

    I resolved this using a different way to initialize, taken from from one of the samples:

    Qt Code:
    1. QList<double> ticks[QwtScaleDiv::NTickTypes];
    2. QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
    3. QList<double> &minorTicks = ticks[QwtScaleDiv::MinorTick];
    4.  
    5. for (int i = 0; i < (20 + 1); i++)
    6. {
    7. if (i % 5 == 0)
    8. {
    9. majorTicks.append(i * 2000);
    10. }
    11. else
    12. {
    13. minorTicks.append(i * 2000);
    14. }
    15. }
    16.  
    17. // mTimeScaleDiv is a AxisScaleDiv member
    18. mTimeScaleDiv = QwtScaleDiv(majorTicks.first(), majorTicks.last(), ticks);
    19. bool isValid = mTimeScaleDiv.isValid(); // For debug reasons
    20.  
    21. // Sets the updated plot
    22. setAxisScaleDiv(QwtPlot::xBottom, mTimeScaleDiv);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: setAxisScaleDiv - my scale div is invalid

    QwtScaleDiv::isValid() is used by the auto scaler inside of QwtPlot and has nothing to do with what everyone expects from the term "valid".

    Of course this flag should be moved somewhere else with a better name.

    Uwe

  4. #4
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setAxisScaleDiv - my scale div is invalid

    Thank you for your reply.

    My concern was not the flag itself, it was that I saw that while replotting, because of this invalid state my scale was generated automatically, and the ticks I defined were ignored. This happened with the first example of code I put in, but my resolved version doesn't have this problem.

Similar Threads

  1. QDateTime Invalid
    By FreePascal in forum Newbie
    Replies: 2
    Last Post: 7th June 2009, 19:35
  2. Invalid plugin
    By reimer in forum Qt Tools
    Replies: 0
    Last Post: 23rd June 2008, 10:43
  3. intersectingStaticSet: row 'x' was invalid
    By Kumosan in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2007, 15:41
  4. QSqlRecord becoming invalid
    By mikro in forum Newbie
    Replies: 5
    Last Post: 3rd October 2006, 18:00
  5. invalid sizeHint()
    By roleroz in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2006, 22:11

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.