Results 1 to 2 of 2

Thread: Distrowatch Example - wrong number of ticks

  1. #1
    Join Date
    Jun 2012
    Posts
    8
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Distrowatch Example - wrong number of ticks

    Hello everyone,

    I am having some trouble customizing the distrowatch example to my needs. The problem occurs, when fewer than 5 bars are added to the plot - for testing I have removed the last 4 entries in the pagehits struct so it looks like that:
    Qt Code:
    1. pageHits[] =
    2. {
    3. { "Arch", 1114, QColor( "DodgerBlue" ) },
    4. { "Debian", 1373, QColor( "#d70751" ) },
    5. { "Fedora", 1638, QColor( "SteelBlue" ) },
    6. { "Mageia", 1395, QColor( "Indigo" ) },
    7.  
    8. };
    To copy to clipboard, switch view to plain text mode 

    In that case, the major ticks and labels get messed up and the output is the following:
    distro.JPG


    I have already tried to come by this by setting a ScaleDiv with the major ticks needed
    Qt Code:
    1. QList<double> ticks[QwtScaleDiv::NTickTypes] =
    2. {
    3. QList<double>(),
    4. QList<double>(),
    5. QList<double>()
    6. << 0
    7. << 1
    8. << 2
    9. << 3
    10. };
    11.  
    12. QwtScaleDiv scdiv(0,3, ticks);
    13. this->axisScaleDraw(axis1)->setScaleDiv(scdiv);
    To copy to clipboard, switch view to plain text mode 

    "this" being the plot and "axis1" being the xBottom-axis.
    This works at first (qDebug()<<scdiv.ticks(2); gives "(0, 1, 2, 3) "), but after the replot the qDebug gives "(0, 0.5, 1, 1.5, 2, 2.5, 3) "

    I have already looked into qwtscaleDiv sources, but was not able to find my mistake - what am I missing?
    I am using Qwt 6.1
    Thanks in advance
    Last edited by bisasatan; 4th January 2014 at 03:03.

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

    Default Re: Distrowatch Example - wrong number of ticks

    Instead of:

    Qt Code:
    1. this->axisScaleDraw(axis1)->setScaleDiv(scdiv);
    To copy to clipboard, switch view to plain text mode 
    do

    Qt Code:
    1. this->setAxisScaleDiv( axis1, scldiv );
    To copy to clipboard, switch view to plain text mode 
    The upper way of assigning the ticks is behind the back of the plot and will have a temporary effect only - until the next call of replot ( or updateAxes() ). The second way is known to the plot and also disables autoscaling.

    Uwe

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

    bisasatan (4th January 2014)

Similar Threads

  1. Hiding axis, but not ticks
    By bisasatan in forum Qwt
    Replies: 1
    Last Post: 31st May 2013, 07:55
  2. Replies: 14
    Last Post: 30th October 2012, 15:45
  3. Replies: 2
    Last Post: 18th July 2012, 17:17
  4. Replies: 1
    Last Post: 5th March 2012, 06:34
  5. how to number the ticks of QSlider
    By babu198649 in forum Newbie
    Replies: 4
    Last Post: 11th June 2008, 13:46

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.