Results 1 to 5 of 5

Thread: Problem with scale ticks

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Problem with scale ticks

    Hi all,

    I want to display a plot with a fixed number of major and minor ticks and I don't want to display for each major tick the corresponding label.

    This is my code:

    Qt Code:
    1. void Form1::init()
    2. {
    3.  
    4. qwtPlot1->setCanvasBackground(Qt::blue);
    5. QwtPlotGrid *grid=new QwtPlotGrid();
    6. grid->setPen(QPen(Qt::white,0,DotLine));
    7. grid->attach(qwtPlot1);
    8.  
    9.  
    10. QwtValueList xytick[QwtScaleDiv::NTickTypes];
    11. for (int i=0;i<11;i++)
    12. xytick[QwtScaleDiv::MajorTick]<<i/10.0;
    13. for (int i=0;i<61;i++)
    14. xytick[QwtScaleDiv::MinorTick]<<i/60.0;
    15.  
    16.  
    17. qwtPlot1->enableAxis(QwtPlot::xTop,true);
    18. qwtPlot1->enableAxis(QwtPlot::yRight,true);
    19.  
    20.  
    21. qwtPlot1->setAxisScaleDiv(QwtPlot::xBottom,QwtScaleDiv(0.0,1.0,xytick));
    22. qwtPlot1->setAxisScaleDiv(QwtPlot::xTop,QwtScaleDiv(0.0,1.0,xytick));
    23. qwtPlot1->setAxisScaleDiv(QwtPlot::yLeft,QwtScaleDiv(0.0,1.0,xytick));
    24. qwtPlot1->setAxisScaleDiv(QwtPlot::yRight,QwtScaleDiv(0.0,1.0,xytick));
    25.  
    26. qwtPlot1->setAxisScaleDraw(QwtPlot::xBottom,new NullScaleDraw());
    27. qwtPlot1->setAxisScaleDraw(QwtPlot::xTop,new NullScaleDraw());
    28. qwtPlot1->setAxisScaleDraw(QwtPlot::yLeft,new NullScaleDraw());
    29. qwtPlot1->setAxisScaleDraw(QwtPlot::yRight,new NullScaleDraw());
    30. }
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. class NullScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. NullScaleDraw()
    5. {
    6. }
    7. virtual QwtText label(double v) const
    8. {
    9. return QString("");
    10. }
    11. };
    To copy to clipboard, switch view to plain text mode 

    This gives me the output displayed in the attached file qwtplot.jpg.

    My question is why the last major ticks of both xBottom and xTop and the first major ticks of both yLeft and yRight axis disappear when I call qwtPlot1->setAxisScaleDraw(...,new NullScaleDraw)?

    Is it possible to avoid the displaying of the tick labels in an easier way?

    Thanks a lot for you help.

    Best regards
    Attached Images Attached Images

Similar Threads

  1. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 12:48
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.