Results 1 to 3 of 3

Thread: SetAxisScale problem

  1. #1
    Join Date
    Aug 2009
    Posts
    33
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default SetAxisScale problem

    I have a big problem when i try to change the scale and i have previous specified a tick list.
    For example

    setAutoReplot( false );

    setAxisScale(QwtPlot::xBottom, -9,5); // I specify a interval
    replot();

    // Here I specify a fix list of ticks

    QwtScaleDiv* scdiv = axisScaleDiv(xBottom);
    QwtValueList tick_lst= scdiv->ticks(QwtScaleDiv::MajorTick);
    tick_lst.clear();
    tick_lst.push_back(-8);
    tick_lst.push_back(-4);
    tick_lst.push_back(-2);
    tick_lst.push_back(1);
    tick_lst.push_back(5);
    scdiv->setTicks(QwtScaleDiv::MajorTick,tick_lst); // set the ticks
    replot();

    The ticks are shown on the xBottom scale, but when i change the the interval with
    setAxisScale(QwtPlot::xBottom, 6,10); the program crashes because of the ticks.

    How can i delete the tick list, or how can i change the ticks?? I tried several methods but without any success.

  2. #2
    Join Date
    Aug 2009
    Posts
    33
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SetAxisScale problem

    I solved the problem.
    First you obtain a pointer to the scale division of the XBottom ax.
    QwtScaleDiv* scdiv = axisScaleDiv(xBottom);

    tick_lst= scdiv->ticks(QwtScaleDiv::MajorTick); // get the tick list

    tick_lst.clear(); // clear the tick list

    tick_list.push_back( value ) // insert new values

    scdiv->setTicks(QwtScaleDiv::MajorTick,tick_lst); // put the tick list back on the ax

    The tick_lst must be declared as private in the class.
    I had several other bugs, i spent 2 days on this bug.

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

    Default Re: SetAxisScale problem

    Better make a copy of the scale division, edit it and reassign it with setAxisScaleDiv().

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2009, 09:05
  2. Replies: 19
    Last Post: 3rd April 2009, 23:17
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 11:21
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

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.