Results 1 to 2 of 2

Thread: QwtScaleWidget: problem with drawing a ColorMap

  1. #1
    Join Date
    Oct 2008
    Location
    Murfreesboro, TN
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question QwtScaleWidget: problem with drawing a ColorMap

    The problem I am having is that whenever I create and then draw a QwtScaleWidget with my defined color map it doesn't render properly. If I give it a range of 0 - 1 it renders fine but when ever I hand it any other range it does not render properly.

    I have listed my code below and some sample screenshots.

    Thanks for your time,
    Jon Jones

    Qt Code:
    1. QwtLinearColorMap colorMap(Qt::darkBlue, Qt::red);
    2. colorMap.addColorStop(0.25, Qt::cyan);
    3. colorMap.addColorStop(0.75, Qt::yellow);
    4.  
    5. QWidget *widget = canvas();
    6.  
    7. QwtScaleWidget *colorBar = new QwtScaleWidget(widget);
    8. colorBar->setColorMap(QwtDoubleInterval(0, 10), colorMap);
    9. colorBar->setColorBarEnabled(true);
    10. colorBar->drawColorBar(&painter, QRect(10,10, 25, 100));
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  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: QwtScaleWidget: problem with drawing a ColorMap

    Assuming you want to use the right axis for your color bar:

    Qt Code:
    1. QwtDoubleInterval range(0, 10);
    2.  
    3. QwtScaleWidget *scale = plot->axisWidget(QwtPlot::yRight);
    4. scale->setColorBarEnabled(true);
    5. scale->setColorMap(range, colorMap);
    6.  
    7. plot->setAxisScale(QwtPlot::yRight,
    8. range().minValue(), range().maxValue() );
    9. plot->enableAxis(QwtPlot::yRight);
    10. plot->replot();
    To copy to clipboard, switch view to plain text mode 

    The spectrogram example shows a colorbar in the range [0, 10].

    Uwe

Similar Threads

  1. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  2. QPainterPath drawing problem
    By shad in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2007, 13:30
  3. drawing problem
    By boss_bhat in forum Newbie
    Replies: 1
    Last Post: 20th September 2006, 10:49

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.