Results 1 to 8 of 8

Thread: QwtPlot axis labels

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot axis labels

    I have this code. I think this has to work in theory. It compiles and runs but no change in text. Whats the problem in my code? If i qDebug the label's text at p it gives me the correct value but after I set the text of label(p) it won't change. Why?


    Qt Code:
    1. QwtScaleDraw *xscale = ui->qwtPlot1->axisScaleDraw(QwtPlot::xBottom);
    2. QString text;
    3. for(int p= 1; p < lenPcm; p++){
    4. text.setNum(p/freq);
    5. xscale->label(p).setText(text);
    6. }
    7. ui->qwtPlot1->setAxisScaleDraw(QwtPlot::xBottom,xscale);
    8. ui->qwtPlot1->replot();
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance!

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

    Default Re: QwtPlot axis labels

    This is your code:

    Qt Code:
    1. class YourScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. virtual QwtText label( double v ) const
    5. {
    6. return QwtScaleDraw::label( pcmToMS( v ) );
    7. }
    8. };
    9.  
    10. plot->setAxisScaleDraw( ..., new YourScaleDraw() );
    To copy to clipboard, switch view to plain text mode 

    If you want to have ticks aligned to ms values read my first answer or set your ticks manually ( what is no option if you want to offer a navigation like zooming/panning to your users ) with QwtPlot::setAxisScaleDiv().

    HTH,
    Uwe

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

    Kutuska (29th August 2012)

  4. #3
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot axis labels

    Thanks a lot! Its working now!
    Another quick question!
    When I load a bigger file (about 3,5 mins or bigger) the Qt crashes and I think it's because qwtplot replots so much. It has to plot about 6 million dots. Its Qt's fault or there's a solution? And when I want to get a playback position indicator cursor (a vertical line) for my plot, it replots so much the Qt can't do it. Can I somehow cache the plot and then do the cursor over only the "picture" of the plot?

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

    Default Re: QwtPlot axis labels

    Quote Originally Posted by Kutuska View Post
    When I load a bigger file (about 3,5 mins or bigger) the Qt crashes and I think it's because qwtplot replots so much.
    Start your debugger and check what's going on. A crash is never because the CPU is busy - it's more likely that you running out of memory.
    And when I want to get a playback position indicator cursor (a vertical line) for my plot, it replots so much the Qt can't do it. Can I somehow cache the plot and then do the cursor over only the "picture" of the plot?
    Sounds like QwtPlotPicker is what you are looking for. Check the bode example ( press the mouse on the canvas ). Instead of a cross hair you can also have a vertical or horizontal line.

    When you try to plot many many dots you might want to try Qwt from SVN trunk. It reintroduces some optimizations like:


    • QwtPlotCurve::FilterPoints
    • QwtPlotCurve::MinimizeMemory


    Especially the first flag should speed up replotting in your situation a lot. But of course the best solution is to filter out points in application code before replotting !

    Uwe

Similar Threads

  1. How to hide axis labels
    By repepo in forum Qwt
    Replies: 5
    Last Post: 10th November 2011, 08:03
  2. QWTPlot x-axis labels with float spacing
    By Pyquestor in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2011, 13:40
  3. Labels on axis.
    By eugene in forum Qwt
    Replies: 5
    Last Post: 6th August 2010, 13:30
  4. Replies: 1
    Last Post: 16th March 2010, 15:23
  5. Axis with more labels
    By rakkar in forum Qwt
    Replies: 1
    Last Post: 11th October 2009, 09:26

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.