30 Apr 16:37
Re: QwtScaleWidget has wrong scale
From: Rainer Thaden <RThaden <at> web.de>
Subject: Re: QwtScaleWidget has wrong scale
Newsgroups: gmane.comp.graphics.qwt.general
Date: 2008-04-30 14:37:52 GMT
Subject: Re: QwtScaleWidget has wrong scale
Newsgroups: gmane.comp.graphics.qwt.general
Date: 2008-04-30 14:37:52 GMT
Hi Klaus,
>
> I tried to use a QwtScaleWidget stand-alone for a colour bar scale which I
> want to use independently from QwtPlot. I looked into the spectrogram example
> and the Qwt source code and finally tried the following:
>
>...
> Surprisingly, the scale does not start at the end of the colour bar, but has
> some offset, thus the numbers do not correctly correspond to the colours
> (which is, however, correct in the spectrogram example, where a QwtPlot axis
> is used); see attached screen shot of my test application. What have I done
> wrong?
I guess the problem is that the scale reserves some space for the
numbers which would otherwise go out of the frame on top and at the
bottom. I had the same problem with a Thermo. You can ask for that
space. I did it like this: Derived my own version of a Thermo (or
colourbar in your case) and added a method scaleMargin as follows
int scaleMargin() const
{
int y1,y2;
scaleDraw()->getBorderDistHint(font(), y1, y2);
int y = qMax(y1,y2);
return y;
}
Then,
thermoLayout = new QVBoxLayout();
int margin=thermoLevel->scaleMargin();
thermoLevel->setMinimumSize(QSize(48, 170-2*margin));
thermoLayout->setContentsMargins(0, margin, 0, margin);
thermoLayout->addWidget(thermoLevel);
gridLayout->addLayout(thermoLayout, 1, 1, 1, 1);
Thus, you shrink the colour-bar to fit the scale.
Hope that helps,
Rainer
-------------------------------------------------------------------------
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
RSS Feed