Re: Draw text on top of both canvas and plot background?
Brought to you by:
rathmann
|
From: Elvis S. <elv...@or...> - 2019-03-12 08:13:25
|
Den tis 12 mars 2019 kl 09:09 skrev Uwe Rathmann <Uwe...@ti...>:
>
> Hi Elvis,
>
> > Hope that makes it more clear.
>
> That doesn't answer my question, but maybe all you want to do is:
Hm, I'm confused. Your question was "Where exactly do you want to draw
the extra text", to which I answered
"The desired_result.png image shows where I want to paint the text
"g/t". I added the text with an image editor. It's right below the top
axis, right aligned with its max label."
and attached a picture showing exactly where I want to draw the text.
What more info do you need? :p
Elvis
>
> class YourScaleDraw : public QwtScaleDraw
> {
> ....
>
> QwtText label( double value ) const override
> {
> auto txt = QLocale().toString( value );
>
> const auto ticks = scaleDiv().ticks[ QwtScaleDiv::MajorTick ];
> if ( !ticks.empty() && value == ticks.last() )
> {
> txt += "\nUnit";
> }
>
> return txt;
> }
> };
>
> plot->setAxisScaleDraw( QwtPlot::xTop, new YourScaleDraw() );
That will draw the text inside the top axis. I want to draw it below
the top axis, straddling the canvas and plot background, as like my
desired_result.png image shows.
Elvis
>
> Uwe
|