Results 1 to 2 of 2

Thread: Stil axis label trouble

  1. #1
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Stil axis label trouble

    still label trouble, here is the code:
    Qt Code:
    1. class NewScaleDraw : public QwtScaleDraw
    2. {
    3. public:
    4. NewScaleDraw()
    5. {
    6. qDebug() << "in newscaledraw ";
    7. invalidateCache();
    8. }
    9.  
    10. virtual QwtText label(double value) const
    11. {
    12. qDebug() << "value = " << value;
    13. double freqLabel = (::centerFreq-(value/2000));
    14. QString strFreqLabel = QString("%1").arg(freqLabel);
    15. return strFreqLabel;
    16. }
    17. };
    18.  
    19. //In the constructor of the plot class
    20. this->setAxisScaleDraw(QwtPlot::xBottom, new NewScaleDraw()); /* this same code is called each time the centerFreq value changes */
    To copy to clipboard, switch view to plain text mode 
    When the setAxisScaleDraw line executes from the plot class constructor, the "value" debug statement returns the following:
    value = 0
    value = 100000
    value = 20000
    value = 40000
    value = 60000
    value = 80000
    value = 0
    value = 95000
    value = 5000
    value = 10000
    value = 15000
    value = 20000
    value = 25000
    value = 30000
    value = 35000
    value = 40000
    value = 45000
    value = 50000
    value = 55000
    value = 60000
    value = 65000
    value = 70000
    value = 75000
    value = 80000
    value = 85000
    value = 90000

    Which I don't understand. So the labels are changed but not to the correct values since the "value" in the NewScaleDraw doesn't start with zero and progress linearly up to 90000. Why is this?

    Second problem is that the NewScaleDraw line is also executed later in the code whenever the centerFreq value changes.
    When that happens, according to the debug output, only the constructor for NewScaleDraw executes, not the QwtText code, so the labels don't change.

    I'm really puzzled.

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

    Default Re: Stil axis label trouble

    Which I don't understand. So the labels are changed but not to the correct values since the "value" in the NewScaleDraw doesn't start with zero and progress linearly up to 90000.
    A scale draw object is responsible for drawing a scale - it doesn't have any effect on the range or tick positions of the scale. Those are calculated by the scale engine or explicitly set by setAxisScaleDiv().

    Second problem is that the NewScaleDraw line is also executed later in the code whenever the centerFreq value changes.
    When that happens, according to the debug output, only the constructor for NewScaleDraw executes, not the QwtText code, so the labels don't change.
    The tick labels are cached - so when you change parameters of the value -> label conversion you have to invalidate the cache. But this is something you should have known from my previous answer.

    Sounds a bit like that you are trying to do something very simple "von Hinten durch die Brust ins Auge".

    Uwe

Similar Threads

  1. QwtPlot x axis label
    By ldg20 in forum Qwt
    Replies: 5
    Last Post: 17th July 2012, 08:02
  2. X axis tick label - font size
    By junhonguk in forum Qwt
    Replies: 5
    Last Post: 26th April 2012, 16:15
  3. Replies: 0
    Last Post: 18th January 2012, 08:41
  4. zooming when mouse hovers axis-label
    By Andreas in forum Qwt
    Replies: 3
    Last Post: 12th December 2011, 10:04
  5. What determines color of text shown as axis label?
    By DrunkenUFOPilot in forum Qwt
    Replies: 1
    Last Post: 24th March 2011, 19:55

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.