Klaus Schneider | 30 Apr 18:58

Re: QwtScaleWidget has wrong scale

Hi,

thanks for your suggestion. I tried it but it didn't work. Still I haven't 
quite understood your solution, though: How can the VBox change the internal 
behaviour of the colour scale, which is one widget with one bounding 
rectange? Can you see an error in my implementation below, or does it simply 
not work with a colour scale?

I tried:

class QwtScaleWidgetX : public QwtScaleWidget
{
Q_OBJECT

public:
   explicit QwtScaleWidgetX(QwtScaleDraw::Alignment alignment, QWidget *parent 
= NULL)
     : QwtScaleWidget(alignment, parent)
   {}
   int scaleMargin() const
   {
      int y1,y2;
      scaleDraw()->getBorderDistHint(font(), y1, y2);
      int y = qMax(y1,y2);
      return y;
   }
};

...

   // Qwt scale widget and stuff
   QwtScaleWidgetX* scale = new QwtScaleWidgetX(QwtScaleDraw::RightScale, 
this);
   QwtLinearScaleEngine se;
   scale->setScaleDiv(se.transformation(),
                      se.divideScale(interval.minValue(), interval.maxValue(), 
8, 5)); // as in QwtPlot::Axis
   scale->setColorBarEnabled(true);
   scale->setColorMap(interval, colormap);
   scale->setTitle("Intensity");
   scale->setMargin(2);
   // layout to adjust scale
   QVBoxLayout* qd = new QVBoxLayout();
   int margin = scale->scaleMargin();
   scale->setMinimumSize(QSize(48, 170-2*margin));
   qd->setContentsMargins(0, margin, 0, margin);
   qd->addWidget(scale);
   // layout
   QVBoxLayout* layout = new QVBoxLayout(this);
   layout->addLayout(qd);
   layout->addWidget(btn_quit);

Thanks again,
Klaus
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

Gmane